Results 1 to 4 of 4

Thread: VB6 to VB .Net listview

  1. #1

    Thread Starter
    Member
    Join Date
    Jun 2012
    Posts
    47

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

  2. #2
    Super Moderator jmcilhinney's Avatar
    Join Date
    May 2005
    Location
    Sydney, Australia
    Posts
    111,221

    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:
    1. 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.
    Why is my data not saved to my database? | MSDN Data Walkthroughs
    VBForums Database Development FAQ
    My CodeBank Submissions: VB | C#
    My Blog: Data Among Multiple Forms (3 parts)
    Beginner Tutorials: VB | C# | SQL

  3. #3

    Thread Starter
    Member
    Join Date
    Jun 2012
    Posts
    47

    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.

  4. #4
    Super Moderator jmcilhinney's Avatar
    Join Date
    May 2005
    Location
    Sydney, Australia
    Posts
    111,221

    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.
    Why is my data not saved to my database? | MSDN Data Walkthroughs
    VBForums Database Development FAQ
    My CodeBank Submissions: VB | C#
    My Blog: Data Among Multiple Forms (3 parts)
    Beginner Tutorials: VB | C# | SQL

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