Windows Mobile中DataGrid的列宽

时间:2013-04-15 01:33:30

标签: windows vb.net mobile

我在编辑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)

此致

1 个答案:

答案 0 :(得分:1)

删除以下行并执行它有效:

  oTableStyle.MappingName = oDotNet.SqlDb.Ds.Tables(0).DefaultView.GetType().Name