Click to See Complete Forum and Search --> : more database fun
Bantam
January 20th, 2003, 08:50 AM
Nobody could answer my question about the datagrid control (see: http://www.codeguru.com/forum/showthread.php?threadid=226294&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
nswan
January 20th, 2003, 12:28 PM
use a listview. much better
i can post some code if you want
Bantam
January 20th, 2003, 01:03 PM
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....
Bantam
January 20th, 2003, 01:06 PM
Uhm, also note that I've never used a listview... ever...
nswan
January 20th, 2003, 01:33 PM
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.
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)
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.
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
codeguru.com
Copyright Internet.com Inc., All Rights Reserved.