Ronald S

Ronald S

  • NA
  • 1
  • 5.5k

How to load (XML) data to datagridview, with combobox in certain column each row, with certain value?

Mar 6 2011 3:23 AM
Hi,
First, I managed to create the XML file from the datagridview, in which column A is combobox. I saved it as "text.xml". Then when I load it back, the column A just show the value from XML source, and did not appear as combobox. So programmatically, how do I:
-set the list for combobox?
-load the (XML) file and set a certain column (in all row) to have combobox with a list of value set previously?
-set the default for each combobox just as the value loaded from XML file?

I've been searching on this and I found it very few discuss about this.
Here is the code I have:
[code]
Private Sub load()
    Dim ds As DataSet = New DataSet
    ds.ReadXml("C:\text.xml")
    Dim dv As DataView = New DataView(ds.Tables(0))
    Dim dt As New DataTable
    dt = ds.Tables(0)

    Dim cb As DataGridViewComboBoxColumn
    DataGridView2.Columns.Clear()
    DataGridView2.Rows.Clear()
    DataGridView2.DataSource = dv

    For i = 0 To dt.Columns.Count - 1
        If dt.Columns(i).Caption = "Status" Then
            Dim c As DataGridViewComboBoxColumn = TryCast(Me.DataGridView1.Columns(i), DataGridViewComboBoxColumn)            
        End If
    Next
    
End Sub        


Please help,

RS

[/code]

Answers (1)