我在编辑datagridview的宽度方面遇到了问题。它没有改变宽度。这是我的源代码。
oDotNet.SqlDb.strCommand = "SELECT TOP 1 ItemCode, ItemName FROM [" & oAPP.oSQLDatabase & "]..OITM"
dgMain.DataSource = oDotNet.SqlDb.Ds.Tables(0).DefaultView
Dim oTableStyle As New DataGridTableStyle
oTableStyle.MappingName = oDotNet.SqlDb.Ds.Tables(0).DefaultView.GetType().Name
Dim oTextBoxColumn As New DataGridTextBoxColumn
oTextBoxColumn.Width = 400
oTextBoxColumn.MappingName = "ItemName"
oTextBoxColumn.HeaderText = "ItemName"
oTableStyle.GridColumnStyles.Add(oTextBoxColumn)
dgMain.TableStyles.Clear()
dgMain.TableStyles.Add(oTableStyle)
此致
答案 0 :(得分:1)
删除以下行并执行它有效:
oTableStyle.MappingName = oDotNet.SqlDb.Ds.Tables(0).DefaultView.GetType().Name