最近在做一个数据库应用程序,需要用DataGrid显示数据,并对每行数据用窗体显示之。因为数据库表之间有关系所以要在DataGrid中使用ComboBox列进行显示,属性窗体则自己做,并使用DataBinding来将数据列绑定到各个控件。发现两个问题:
1、属性窗体中的数据改变时,不能马上在DataGrid中有相应改变
2、有没有好的ComboBox列控件可以用,要知道.net framework只提供了DataGridTextBoxColumn和DataGridBoolColumn两种列。另外不知道VS2005中有没有对DataGrid的功能有所加强?实在不行就转向VS2005开发了

解决方案 »

  1.   

    请参考:(在Part 2中,有DataGridComboBoxColumn的示例)
    Styling with the DataGridColumnStyle
    Part 1:
    http://msdn.microsoft.com/smartclient/default.aspx?pull=/library/en-us/dnwinforms/html/datagridcolumnstyle1.aspPart 2:
    http://msdn.microsoft.com/smartclient/default.aspx?pull=/library/en-us/dnwinforms/html/datagridcolumnstyle2.asp
      

  2.   

    另外,DataGridBoolColumn在Part 1有。
      

  3.   

    关于你后面的问题:
    >>>>VS2005中有没有对DataGrid的功能有所加强?我这里还没有安装VS 2005的正式版,只安装了VS 2005 beta 2,而且确定beta 2里面是有这方面的功能的。
    在VS 2005 beta 2,名称改成了DatatGridView控件,
    在DataGridView上,右键->Edit Columns...,选择你需要设置的列,然后设置ColumnType。
    可以选择的ColumnType有6个:
    DataGridViewButtonColumn
    DataGridViewCheckBoxColumn
    DataGridViewComboBoxColumn
    DataGridViewImageColumn
    DataGridViewLinkColumn
    DataGridViewTextBoxColumn
      

  4.   

    再请问DataGrid中的数据校验如何进行?