Welcome to Dream.In.Code
Getting VB.NET Help is Easy!

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!




Displaying Data on Form

 
Reply to this topicStart new topic

Displaying Data on Form

gayle111
24 Jul, 2008 - 04:59 AM
Post #1

New D.I.C Head
*

Joined: 19 May, 2008
Posts: 6

I have Visual Basic.Net 2008.

I would like to display a recordset on a forum something like this:


Item: White Shirt / mens Size: 16.5
Brand: Garjano Price: $56.50
Available Online: Yes In Stores: Yes
Current Stock: 43

Item: White Shirt / woman Size: 16.5
Brand: Garjano Price: 66.50
Available Online: Yes In Stores: Yes
Current Stock: 32

Item: Blue Shirt / mens Size: 16.0
Brand: Garjano Price: $56.50
Available Online: No In Stores: Yes
Current Stock: 3

Where each record makes up several lines, and if there are more than fit on one screen there would be a vertical scroll bar.

What component/object should I be looking at for displaying this kind of data on the form?

User is offlineProfile CardPM
+Quote Post

Jayman
RE: Displaying Data On Form
24 Jul, 2008 - 08:19 AM
Post #2

Student of Life
Group Icon

Joined: 26 Dec, 2005
Posts: 6,941



Thanked: 42 times
Dream Kudos: 500
Expert In: C#, VB.NET, Java

My Contributions
Moved to VB.NET where it will get the attention it deserves.

You could display the data in a Listbox.
User is offlineProfile CardPM
+Quote Post

gayle111
RE: Displaying Data On Form
24 Jul, 2008 - 10:52 AM
Post #3

New D.I.C Head
*

Joined: 19 May, 2008
Posts: 6

QUOTE(jayman9 @ 24 Jul, 2008 - 09:19 AM) *

Moved to VB.NET where it will get the attention it deserves.

You could display the data in a Listbox.


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.

User is offlineProfile CardPM
+Quote Post

kikz
RE: Displaying Data On Form
24 Jul, 2008 - 12:16 PM
Post #4

New D.I.C Head
*

Joined: 21 Jul, 2008
Posts: 32



Thanked: 1 times
My Contributions
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.
User is offlineProfile CardPM
+Quote Post

Jayman
RE: Displaying Data On Form
24 Jul, 2008 - 12:37 PM
Post #5

Student of Life
Group Icon

Joined: 26 Dec, 2005
Posts: 6,941



Thanked: 42 times
Dream Kudos: 500
Expert In: C#, VB.NET, Java

My Contributions
QUOTE(gayle111 @ 24 Jul, 2008 - 11:52 AM) *

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.


Attached thumbnail(s)
Attached Image
User is offlineProfile CardPM
+Quote Post

gayle111
RE: Displaying Data On Form
24 Jul, 2008 - 12:48 PM
Post #6

New D.I.C Head
*

Joined: 19 May, 2008
Posts: 6

QUOTE(jayman9 @ 24 Jul, 2008 - 01:37 PM) *

QUOTE(gayle111 @ 24 Jul, 2008 - 11:52 AM) *

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.
User is offlineProfile CardPM
+Quote Post

gayle111
RE: Displaying Data On Form
24 Jul, 2008 - 01:03 PM
Post #7

New D.I.C Head
*

Joined: 19 May, 2008
Posts: 6

QUOTE(kikz @ 24 Jul, 2008 - 01:16 PM) *

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?
User is offlineProfile CardPM
+Quote Post

Jayman
RE: Displaying Data On Form
24 Jul, 2008 - 02:50 PM
Post #8

Student of Life
Group Icon

Joined: 26 Dec, 2005
Posts: 6,941



Thanked: 42 times
Dream Kudos: 500
Expert In: C#, VB.NET, Java

My Contributions
QUOTE(gayle111 @ 24 Jul, 2008 - 01:48 PM) *

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.
User is offlineProfile CardPM
+Quote Post

gayle111
RE: Displaying Data On Form
24 Jul, 2008 - 03:48 PM
Post #9

New D.I.C Head
*

Joined: 19 May, 2008
Posts: 6

QUOTE(jayman9 @ 24 Jul, 2008 - 03:50 PM) *

QUOTE(gayle111 @ 24 Jul, 2008 - 01:48 PM) *

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?
User is offlineProfile CardPM
+Quote Post

Jayman
RE: Displaying Data On Form
24 Jul, 2008 - 09:10 PM
Post #10

Student of Life
Group Icon

Joined: 26 Dec, 2005
Posts: 6,941



Thanked: 42 times
Dream Kudos: 500
Expert In: C#, VB.NET, Java

My Contributions
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.
User is offlineProfile CardPM
+Quote Post

gayle111
RE: Displaying Data On Form
25 Jul, 2008 - 06:09 AM
Post #11

New D.I.C Head
*

Joined: 19 May, 2008
Posts: 6

QUOTE(jayman9 @ 24 Jul, 2008 - 10:10 PM) *

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?
User is offlineProfile CardPM
+Quote Post

Jayman
RE: Displaying Data On Form
25 Jul, 2008 - 07:48 AM
Post #12

Student of Life
Group Icon

Joined: 26 Dec, 2005
Posts: 6,941



Thanked: 42 times
Dream Kudos: 500
Expert In: C#, VB.NET, Java

My Contributions
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.

Give it a try.
User is offlineProfile CardPM
+Quote Post

Fast ReplyReply to this topicStart new topic
Time is now: 12/2/08 03:34PM

Live VB.NET Help!

VB.NET Tutorials

Reference Sheets

VB.NET Snippets

DIC Chatroom

Bye Bye Ads

Monthly Drawing

Thumb Drive

Top Contributors

Top 10 Kudos This Month