Fill Combobox with DV

  • Thread starter Thread starter ken
  • Start date Start date
K

ken

I would like to fill a combobox with the values of one
column of the dataview I am using. When I set it up the
way I expect it would be, I get every row in the combobox
says: System.Data.DataRowView

If I click on one, it navigates to the right place. Any
idea how I would get the System.Data.DataRowView to show
the actual values in the column?

Thanks
 
Hi Ken,

I send bellow some code to fill a complete combobox with a datatable and a
dataset.

What you tell can also come, because of that the index change event is fired
every time that the combobox is loaded and you are looking to a still empty
combobox.

To avoid that, you can set a "switch", "boolean" that you set to true in the
load event and thant test that in the selectedindexchanged event.

This is some code to fill a combobox
\\\
Dim dt As New DataTable
Dim dc As New DataColumn
Dim dr As DataRow
dc.DataType = System.Type.GetType("System.String")
dc.ColumnName = "i"
dt.Columns.Add(dc)
For i = 1 To 10
dr = dt.NewRow()
dr("i") = (i * 10).ToString
dt.Rows.Add(dr)
Next i
Dim dv As DataView = New DataView(dt)
dv.Sort = "i DESC"
Me.ComboBox2.DisplayMember = "i"
Me.ComboBox2.DataSource = dv
Me.ComboBox2.SelectedIndex = 5
///
 
Back
Top