我有一个VB的例子,但是有几行不知道如何改成C#。求教:
numRows = CType(dataGrid1.DataSource, DT).Rows.Count;——CType如何实现size = g.MeasureString(dataGrid1(i, col).ToString, dataGrid1.Font, 500, sf);——运行时说
“ComboBoxInDataGrid.AutoSizeControl.dataGrid1”表示“字段”,此处应为“方法”dataGrid1.TableStyles("Students").GridColumnStyles(col).Width=CType(width,Integer);——“System.Windows.Forms.DataGrid.TableStyles”表示“属性”,此处应为“方法”
(其中的“Students"如果不是这么具体,应该写什么/)我实在是看不懂。请大家帮忙解答一下。如果大家有详细的例子,也请贴上来给我看一下吧。谢谢。
numRows = CType(dataGrid1.DataSource, DT).Rows.Count;——CType如何实现size = g.MeasureString(dataGrid1(i, col).ToString, dataGrid1.Font, 500, sf);——运行时说
“ComboBoxInDataGrid.AutoSizeControl.dataGrid1”表示“字段”,此处应为“方法”dataGrid1.TableStyles("Students").GridColumnStyles(col).Width=CType(width,Integer);——“System.Windows.Forms.DataGrid.TableStyles”表示“属性”,此处应为“方法”
(其中的“Students"如果不是这么具体,应该写什么/)我实在是看不懂。请大家帮忙解答一下。如果大家有详细的例子,也请贴上来给我看一下吧。谢谢。
}看看 MSDN 中对 TableStyle 的详细介绍~~
有许多有关datagrid的例子,当然也包括你要的自动调整的