A
Apostolos Doudakmanis
Guest
I'm making an MDI application
I have a custom control embedded in the child form
Custom control contains a MySQL database and a DataGridView
It shows me the message:
An unhandled exception of type 'System.ArgumentException' occurred in System.Windows.Forms.dll
and stops at ....
DataGridView1.DataSource = view
OpenDB()
ds = New DataSet
tables = ds.Tables
'-------------------------------------------------------------------------------------
' Third Column
da = New MySqlDataAdapter("Select id,f1 From Pin1f3;", myConnection1)
da.Fill(ds, "Pin1f3")
'-------------------------------------------------------------------------------------
da = New MySqlDataAdapter("Select * from " & NameTable, myConnection1) 'Change items to your database name
da.Fill(ds, NameTable)
DataGridView1.DataSource = ds
DataGridView1.DataMember = ds.Tables(1).TableName
'-------------------------------------------------------------------------------------
Dim view As New DataView(tables(1))
source1.DataSource = view
DataGridView1.DataSource = view
DataGridView1.Columns(0).HeaderText = "A/A"
DataGridView1.Columns(1).HeaderText = "Disc Name"
DataGridView1.Columns(1).Width = 150
DataGridView1.Columns(2).HeaderText = "Disc"
DataGridView1.Columns(2).Width = 100
DataGridView1.Columns(3).HeaderText = "Disc Type"
DataGridView1.Columns(3).Width = 150
'-------------------------------------------------------------------------------------
' First DataGridViewMultiColumnComboColumn
'-------------------------------------------------------------------------------------
Dim positionf3 As Integer = DataGridView1.Columns.Count
If DataGridView1.Columns.Contains("f3") Then
positionf3 = DataGridView1.Columns("f3").Index
'create the multicolumncombo column
Dim newColumnF3 As New DataGridViewMultiColumnComboColumn()
With newColumnF3
.CellTemplate = New DataGridViewMultiColumnComboCell()
.DataSource = ds.Tables("Pin1f3")
.HeaderText = "Disc Type"
.DisplayMember = "f1"
.ValueMember = "id"
.DataPropertyName = "f3"
.DisplayStyle = DataGridViewComboBoxDisplayStyle.Nothing
End With
DataGridView1.Columns.Remove("f3")
DataGridView1.Columns.Insert(positionf3, newColumnF3)
DataGridView1.Columns(positionf3).Width = 150
End If
CloseDB()
What did I do wrong?
Continue reading...
I have a custom control embedded in the child form
Custom control contains a MySQL database and a DataGridView
It shows me the message:
An unhandled exception of type 'System.ArgumentException' occurred in System.Windows.Forms.dll
and stops at ....
DataGridView1.DataSource = view
OpenDB()
ds = New DataSet
tables = ds.Tables
'-------------------------------------------------------------------------------------
' Third Column
da = New MySqlDataAdapter("Select id,f1 From Pin1f3;", myConnection1)
da.Fill(ds, "Pin1f3")
'-------------------------------------------------------------------------------------
da = New MySqlDataAdapter("Select * from " & NameTable, myConnection1) 'Change items to your database name
da.Fill(ds, NameTable)
DataGridView1.DataSource = ds
DataGridView1.DataMember = ds.Tables(1).TableName
'-------------------------------------------------------------------------------------
Dim view As New DataView(tables(1))
source1.DataSource = view
DataGridView1.DataSource = view
DataGridView1.Columns(0).HeaderText = "A/A"
DataGridView1.Columns(1).HeaderText = "Disc Name"
DataGridView1.Columns(1).Width = 150
DataGridView1.Columns(2).HeaderText = "Disc"
DataGridView1.Columns(2).Width = 100
DataGridView1.Columns(3).HeaderText = "Disc Type"
DataGridView1.Columns(3).Width = 150
'-------------------------------------------------------------------------------------
' First DataGridViewMultiColumnComboColumn
'-------------------------------------------------------------------------------------
Dim positionf3 As Integer = DataGridView1.Columns.Count
If DataGridView1.Columns.Contains("f3") Then
positionf3 = DataGridView1.Columns("f3").Index
'create the multicolumncombo column
Dim newColumnF3 As New DataGridViewMultiColumnComboColumn()
With newColumnF3
.CellTemplate = New DataGridViewMultiColumnComboCell()
.DataSource = ds.Tables("Pin1f3")
.HeaderText = "Disc Type"
.DisplayMember = "f1"
.ValueMember = "id"
.DataPropertyName = "f3"
.DisplayStyle = DataGridViewComboBoxDisplayStyle.Nothing
End With
DataGridView1.Columns.Remove("f3")
DataGridView1.Columns.Insert(positionf3, newColumnF3)
DataGridView1.Columns(positionf3).Width = 150
End If
CloseDB()
What did I do wrong?
Continue reading...