Join 136,456 VB.NET Programmers for FREE! Get instant access to thousands of VB.NET experts, tutorials, code snippets, and more! There are 1,918 people online right now. Registration is fast and FREE... Join Now!
If you want to display each field of each record on its own line you can subclass the DataGird or DataViewGrid controls to enable this. This would achieve similar functionality to using templates in ASP.NET repeater controls.
The DataGrid would contain only one column and you can subclass the cell to contain the 8 lables, 2 per line, to represent the field names and values.
As far as I know listbox is one line per record. I have too much data to put on one line, I want to have several lines per data record.
I think you have been misinformed.
A ListBox displays multiple lines, hence the reference to List in the name of the control.
See the attached image displaying your data in a ListBox.
And yes, when the list grows longer a scrollbar will show up.
The image looks great. But is this data bound or do I need to fill it? Of course if fill it by hand I can do this, but I want it bound to the dataset so that I don't need to fill this each time.
If you want to display each field of each record on its own line you can subclass the DataGird or DataViewGrid controls to enable this. This would achieve similar functionality to using templates in ASP.NET repeater controls.
The DataGrid would contain only one column and you can subclass the cell to contain the 8 lables, 2 per line, to represent the field names and values.
Well it's not that I want each field on a separate line, but in some cases I have a wide recordset (many fields) and putting it on a straight line like a typical DGV won't work (I don't want to pan right/left). So one row of the dataset would span several lines, laid out accordingly, depending on the data. I see this on the web a lot (I guess using ASP which I have never worked with, and I don't believe I can mix a ASP component with VB). Basically it's would be the same as an Access Continuos Form. But your mention of subclass sounds like it could do the job - but I think this is beyond my knowledge of vb.net. Is there an example or tutorial you can direct me to that should show me how to do this?
The image looks great. But is this data bound or do I need to fill it? Of course if fill it by hand I can do this, but I want it bound to the dataset so that I don't need to fill this each time.
Yes, you can databind the dataset via the DataSource property.
However, if the results stored in the dataset are not exactly as you want them to be displayed already, then you will have to manually add them to the ListBox and format them as you add each line to the ListBox.
The image looks great. But is this data bound or do I need to fill it? Of course if fill it by hand I can do this, but I want it bound to the dataset so that I don't need to fill this each time.
Yes, you can databind the dataset via the DataSource property.
However, if the results stored in the dataset are not exactly as you want them to be displayed already, then you will have to manually add them to the ListBox and format them as you add each line to the ListBox.
So if I have a row of 12 fields I can bind it to a Listbox by binding the first three fields to line 1 of the listbox, the next three fields to the next line, etc. and then it will repeat itself automatically?
If the data is stored in the DataSet exactly as you want it to appear visually, then you can simply bind it to the ListBox. Otherwise, you will need to manually add it to the Listbox while formatting the data to get the appearance you want.
If the data is stored in the DataSet exactly as you want it to appear visually, then you can simply bind it to the ListBox. Otherwise, you will need to manually add it to the Listbox while formatting the data to get the appearance you want.
so can you connect one row of a recordset to 3 rows on listbox - have it databound, not do this manually?
No. As I already stated, twice now, if it needs to be listed in 3 rows then it needs to already be in 3 rows in the dataset. However, this is highly unlikely, especially if you are pulling the data from database.
You will need to manually add them to the ListBox. This is not a very difficult task.