|
-
Jul 27th, 2012, 02:05 AM
#1
Thread Starter
Member
VB6 to VB .Net listview
guys its my first tym to use vb .net in a project. how can i populate a listview from an ADODB recordset? i've searched so far in the net but still cant understand on how to do it using ADODB. Please give me some hint to start with..
thanks in advance..
-
Jul 27th, 2012, 02:13 AM
#2
Re: VB6 to VB .Net listview
Two things:
1. Don't use ADODB.
2. Don't use a ListView.
We're not in VB6 any more Toto! Use ADO.NET and populate a DataTable using a data adapter and then bind that DataTable to a DataGridView. Follow the CodeBank link in my signature and check out my thread on Retrieving & Saving Data for example code on populating the DataTable. As for binding, it's a one-liner:
vb.net Code:
myDataGridView.DataSource = myDataTable
That will create all the columns and all the rows automatically. If you need something other than the default behaviour then you can create some or all of the columns in the designer and then still use that one line of code.
-
Jul 27th, 2012, 02:30 AM
#3
Thread Starter
Member
Re: VB6 to VB .Net listview
ahm can i know why u advice not to use listview? i find it very functional and flexible in VB6 and i believe it still has its capabilities in .NET
Last edited by dexjel140503; Jul 27th, 2012 at 02:38 AM.
-
Jul 27th, 2012, 02:44 AM
#4
Re: VB6 to VB .Net listview
The ListView is not a proper grid control. If you are not using ListView-specific features, i.e. multiple views or grouping, then the ListView is generally a poor choice for tabular data. The DataGridView is a proper grid control and is far more functional and flexible than a ListView for displaying tabular data. For a start it supports data-binding, plus it has several in-built column types and allows you to create your own to display and edit data any way you want.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|