Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations wOOdy-Soft on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Is there a limit in the number of columns in a listview?

Status
Not open for further replies.

TheBugSlayer

Programmer
Sep 22, 2002
887
US
I have the following code in my Sub:
Code:
[COLOR=green]
...
Dim dr As IDataReader = db.ExecuteReader(db.GetStoredProcCommand("p_MyTable_SELECT"))

If dr.Read() Then
                If IsFirstLoad Then
                    Dim Schema As System.Data.DataTable = dr.GetSchemaTable()
                    Dim Row As DataRow
                    For Each Row In Schema.Rows
                        If Row("ColumnName") <> "Practice_Code" And _
                           Row("ColumnName") <> "Practice_Description" Then
                            Dim h As New ColumnHeader
                            h.Text = Row("ColumnName")
                            h.Tag = Row("ColumnName")
                            h.Width = Convert.ToInt32(Row("ColumnSize"))
                            lvPractices.Columns.Add(h)
                        End If
                    Next
                    IsFirstLoad = False
                End If
...
[/color]

The Practice_Code and Practice_Description columns are added at design time and are the only ones I want visible.

The table contains 32 fields, however Schema.Rows only contains 23 rows, in other words, the listview only has 23 columns. Is there a limit in the number of column headers?

I am trying to have the dataset stay in memory somehow. Since there is already a listview containing the records, I did not want to persist the data reader.

Any help is appreciated.
 
Oh sorry, the original code is:
Code:
[COLOR=green]
...
Dim dr As IDataReader = db.ExecuteReader(db.GetStoredProcCommand("p_MyTable_SELECT"))

If dr.Read() Then
                If IsFirstLoad Then
                    Dim Schema As System.Data.DataTable = dr.GetSchemaTable()
                    Dim Row As DataRow
                    For Each Row In Schema.Rows
                        If Row("ColumnName") <> "Practice_Code" And _
                           Row("ColumnName") <> "Practice_Description" Then
                            Dim h As New ColumnHeader
                            h.Text = Row("ColumnName")
                            h.Tag = Row("ColumnName")
                           [COLOR=red] h.Width = 0[/color]
                            lvPractices.Columns.Add(h)
                        End If
                    Next
                    IsFirstLoad = False
                End If
...
[/color]
I am only displaying two columns. Thabnks.
 
rjoubert, I think that is for a custom piece of software called AutoHotKey... Not for .NET.

The Columns property is a Collection, so for all intents and purposes you should be able to put as many as you need in there.


Senior Software Developer
 
Sirius...you are correct sir. Sorry 'bout that...I guess I should read the content before I go posting a link.

I was just testing the limit, and I was able to add nearly 700 columns without any problems.
 
Thank you guys for trying to help me. I was not thinking straight, or maybe too hard and I missed the small thing:

p_MyTable_SELECT returned 23/32 fields. That is why! I changed the SELECT statement to include all columns. It's all good.

Thanks again.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top