Listview


DevX Home    Today's Headlines   Articles Archive   Tip Bank   Forums   

Results 1 to 9 of 9

Thread: Listview

  1. #1
    Join Date
    May 2010
    Posts
    6

    Listview

    hi, guys
    i need help with listview, after populate it with data, and after recall it after data inserted, av a repeated column head.
    please help me out

  2. #2
    Join Date
    Jun 2009
    Posts
    135
    Huh??? Okay, I'll take a stab at deciphering your question...

    You have a LV control that you use for data entry and display, but when you go to redisplay the data that you entered, you have a duplicate column like two first name columns. Well if that is right, look at your sql statement where you select the records from the database to see if you have something like...

    strSQL = "SELECT fname, fname, lname, dob FROM tablename WHERE ...

    If that is not the problem and the control is not a bound control, then have a look at where you set the columns up and populate the data...



    Good Luck

  3. #3
    Join Date
    May 2010
    Posts
    6
    hi, please found below the code for the list view fill
    Code:
    Private Sub PopulateListView()
            Dim rdGetData As SqlClient.SqlDataReader
            Dim intCount As Decimal = 0
            Dim lobjCommand As SqlCommand
    
            Me.ListView1.Items.Clear()
    
            Me.ListView1.View = View.Details
    
    
            ListView1.Columns.Add("Account Type", 100, HorizontalAlignment.Left)
            ListView1.Columns.Add("Account Type No", 110, HorizontalAlignment.Left)
            ListView1.Columns.Add("Account Name", 100, HorizontalAlignment.Left)
            ListView1.Columns.Add("Account No", 100, HorizontalAlignment.Left)
    
            Dim MySQL As String = "SELECT AcctType, AccTypeNo, AcctName, AcctNo FROM tblChartAcct ORDER BY AcctType"
    
    
            Try
                lobjCommand = New System.Data.SqlClient.SqlCommand(MySQL, SQLConn)
                SQLConn.Open()
                rdGetData = lobjCommand.ExecuteReader
    
                While rdGetData.Read()
                    Dim lvl As New ListViewItem(New String() {rdGetData.GetValue(0), rdGetData.GetValue(1).ToString, rdGetData.GetValue(2), rdGetData.GetValue(3).ToString})
                    'MsgBox(rdGetData.GetString(2))
                    Me.ListView1.Items.Add(lvl)
                End While
    
    
                rdGetData.Close()
    
            Catch ex As Exception
                MessageBox.Show(ex.ToString)
    
            Finally
    
                SQLConn.Close()
            End Try
    
    
        End Sub
    End Class
    and i have the code, it ok
    please, help
    Last edited by Hack; 05-26-2010 at 11:59 AM.

  4. #4
    Join Date
    Apr 2007
    Location
    Sterling Heights, Michigan
    Posts
    8,666
    What version of Visual Basic are you using?
    I don't answer coding questions via PM or Email. Please post a thread in the appropriate forum section.
    Please use [Code]your code goes in here[/Code] tags when posting code.
    Before posting your question, did you look here?
    Got a question on Linux? Visit our Linux sister site.
    Modifications Required For VB6 Apps To Work On Vista

  5. #5
    Join Date
    May 2010
    Posts
    6
    i am using visual studio basic 2008 for the coding

  6. #6
    Join Date
    Apr 2007
    Location
    Sterling Heights, Michigan
    Posts
    8,666
    Then I will move your thread to the correct forum section, which is here, in .NET

    Does the code you posted in Post #3 work or not work for you?

    I am not completely understanding your question.
    I don't answer coding questions via PM or Email. Please post a thread in the appropriate forum section.
    Please use [Code]your code goes in here[/Code] tags when posting code.
    Before posting your question, did you look here?
    Got a question on Linux? Visit our Linux sister site.
    Modifications Required For VB6 Apps To Work On Vista

  7. #7
    Join Date
    May 2010
    Posts
    6
    it works fine, if i call the module class in form load, but after insert record into the database and recall the same method, i have a mutlipe column heading. e.g all the column head will repeated without data but blank.

    thank you for your help

  8. #8
    Join Date
    Apr 2007
    Location
    Sterling Heights, Michigan
    Posts
    8,666
    Then remove these lines from the sub routine. You don't need them recreated each time you run it
    Code:
    ListView1.Columns.Add("Account Type", 100, HorizontalAlignment.Left)
            ListView1.Columns.Add("Account Type No", 110, HorizontalAlignment.Left)
            ListView1.Columns.Add("Account Name", 100, HorizontalAlignment.Left)
            ListView1.Columns.Add("Account No", 100, HorizontalAlignment.Left)
    Just delete those lines altogether and create the column headings from the listview property page in design.
    I don't answer coding questions via PM or Email. Please post a thread in the appropriate forum section.
    Please use [Code]your code goes in here[/Code] tags when posting code.
    Before posting your question, did you look here?
    Got a question on Linux? Visit our Linux sister site.
    Modifications Required For VB6 Apps To Work On Vista

  9. #9
    Join Date
    May 2010
    Posts
    6
    hi,
    thanks for the help you, hack and Good morning

Similar Threads

  1. Replies: 1
    Last Post: 09-16-2006, 07:37 PM
  2. ListView Control and Custom Sorting
    By Birhanu in forum VB Classic
    Replies: 0
    Last Post: 11-09-2001, 03:26 PM
  3. ListView Control and Custom Sorting
    By Birhanu in forum VB Classic
    Replies: 0
    Last Post: 11-09-2001, 03:26 PM
  4. Listview boxes
    By Kenneth in forum VB Classic
    Replies: 0
    Last Post: 04-24-2001, 11:04 AM
  5. Re: Listview Item structure HELP.
    By Diego in forum VB Classic
    Replies: 1
    Last Post: 08-28-2000, 08:15 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
HTML5 Development Center
 
 
FAQ
Latest Articles
Java
.NET
XML
Database
Enterprise
Questions? Contact us.
C++
Web Development
Wireless
Latest Tips
Open Source


   Development Centers

   -- Android Development Center
   -- Cloud Development Project Center
   -- HTML5 Development Center
   -- Windows Mobile Development Center