CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 5 of 5
  1. #1
    Join Date
    Jan 2003
    Posts
    48

    more database fun

    Nobody could answer my question about the datagrid control (see: http://www.codeguru.com/forum/showth...4&goto=newpost ), and to recap, I wanted to show a number of records in a datagrid and allow the user to double click on one row (record) and work with whichever one was chosen.

    If it's not possible with the datagrid, are there any other suggestions? I just need to show possibly a whole bunch of records and allow the user to choose one as seemlessly as possible.

    I appreciate the help guys

    -Jacob

  2. #2
    Join Date
    Jan 2003
    Posts
    14
    use a listview. much better

    i can post some code if you want

  3. #3
    Join Date
    Jan 2003
    Posts
    48
    Yes, please! But don't forget, there are going to be a large number of records with a large number of fields, and the users need to see them all, even if only one of the fields out of one of the records will be used.

    For example, if you're searching for a guy named "Joe Blow" in the city of "Hobokin", and there are 5 Joe blows, and the one you want lives at 334 East First Avenue, but the record has it as 334 E. 1st Ave., then you'll have to choose the criteria JOE BLOW from HOBOKIN and see all the possibilities to know which one to work with...

    hope this is coherent....

  4. #4
    Join Date
    Jan 2003
    Posts
    48
    Uhm, also note that I've never used a listview... ever...

  5. #5
    Join Date
    Jan 2003
    Posts
    14
    ok,

    create a list view on your project and leave it called listview1 for simplicity.

    add columns to the list view by using the following code.
    Code:
    ListView1.View = View.Details
            ListView1.Columns.Add("column1", 100, HorizontalAlignment.Left)
            ListView1.Columns.Add("column2", 100, HorizontalAlignment.Left)
            ListView1.Columns.Add("column3", 100, HorizontalAlignment.Left)
    add items to the listview by the following code (with a dataset)
    Code:
    Dim lstItem As New ListViewItem()
    lstItem = ListView1.Items.Add(dataset2.Tables(0).Rows(intCount).Item(0))
                           
    lstItem.SubItems.Add(dataset2.Tables(0).Rows(intCount).Item(2))
                            lstItem.SubItems.Add(dataset2.Tables(0).Rows(intCount).Item(3))
                            lstItem.SubItems.Add(dataset2.Tables(0).Rows(intCount).Item(4))
                            lstItem.SubItems.Add(dataset2.Tables(0).Rows(intCount).Item(5))
                            lstItem.SubItems.Add(dataset2.Tables(0).Rows(intCount).Item(6))
    when a user double clicks on a item in the listview use this code to get the info out.

    Code:
    Dim lstItem As New ListViewItem()
    
    lstItem = ListView1.SelectedItems(0)
    column1value = lstItem.Text
    column2value = lstItem.SubItems(1).Text
    column3value = lstItem.SubItems(3).Text
    column4value = lstItem.SubItems(5).Text
    and that should be it. Not sure how it will work with large amounts of records, you can but try!

    Hope this helps.
    Nick

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  





Click Here to Expand Forum to Full Width

Featured