请教大家在(winfrom)里,怎么把checkBox添加到dataGrid行里!
多谢!!1

解决方案 »

  1.   

    2005 DataGridView 带这个东西,直接用就可以等等吧
      

  2.   

    /// <summary>
    /// 应用程序的主入口点。
    /// </summary>
    [STAThread]
    static void Main() 
    {
    Application.Run(new Form1());
    } private void button1_Click(object sender, System.EventArgs e)
    {
    connectionString="Provider=sqloledb;Data Source=zdq;Initial Catalog=MesDb;User Id=sa;Password=zdq;";
    Connection = new OleDbConnection( connectionString );
            Connection.Open();
     OleDbDataAdapter da= new OleDbDataAdapter("SP_GET_PPMES202",Connection);
    DataSet ds = new DataSet();
    da.Fill(ds,"table");
    DataTable dt = new DataTable();
    dt = ds.Tables["table"]; DataColumn dtcCheck = new DataColumn("aaa"); 
    dtcCheck.DataType = System.Type.GetType("System.Boolean"); 
    dtcCheck.DefaultValue = false;  dt.Columns.Add(dtcCheck);  dataGrid1.DataSource = dt;  } private void button2_Click(object sender, System.EventArgs e)
    {
    DataTable ds_Table=(DataTable)this.dataGrid1.DataSource;
    DataRow [] dr=null;
    for(int i=0;i<ds_Table.Rows.Count;i++)
    {
    dr=ds_Table.Select("aaa=1");
    }
              
    for(int i=0;i<dr.Length;i++)
    {
    MessageBox.Show(dr[i]["AUFNR"].ToString());
    MessageBox.Show(dr[i]["SUB_AUFNR"].ToString());
    MessageBox.Show(dr[i]["MATNR"].ToString());
    MessageBox.Show(dr[i]["MAKT_Z"].ToString());
    } }
    }
    }
      

  3.   

    参考一下:
    http://dev.csdn.net/develop/article/18/18615.shtm
    http://dev.csdn.net/develop/article/21/21585.shtm
    http://dev.csdn.net/develop/article/21/21294.shtm
      

  4.   

    楼上给的,都是asp的,有没有winform的
    我也正想学习,关注一下
      

  5.   

    兄弟们
    有WINForm的资料吗??
      

  6.   

    //winform也一样啊。
    DataTable dt = new DataTable();
    dt = ds.Tables["table"];DataColumn dtcCheck = new DataColumn("aaa"); 
    dtcCheck.DataType = System.Type.GetType("System.Boolean"); 
    dtcCheck.DefaultValue = false; dt.Columns.Add(dtcCheck); //这就加进去了。
    dataGrid1.DataSource=dt;dataGrid1.DataSource = dt;
      

  7.   

    http://www.bypro.net/20069/ShowPost.aspx到上面的地址下载我写的软件,里面有你想要的东西。
      

  8.   

    按照楼上zdq801104的代码是可以添加CheckBox进去,但是这个CheckBox有3种选择,有什么办法改变选择的可能性,改为两种。
      

  9.   

    http://www.syncfusion.com/FAQ/WindowsForms/Default.aspx#44
      

  10.   

    http://shixianyong.cnblogs.com/archive/2005/06/15/174865.html
      

  11.   

    fifadeke(咖啡淡了) 
    你好!请把代码发到
    谢谢!
      

  12.   

    好帖,正在思考该用listview还是datagrid的问题,谢了先......
      

  13.   

    怎么都是给的asp.net的例子啊,我也碰到这个问题。
      

  14.   

    WinForm中DataGrid需要添加CheckBox嗎?
    給DataGrid添加一個DataGridTableStyle然后添加一個System.Windows.Forms.DataGridBoolColumn不就是你想要的CheckBox嗎? 試試看﹐不用寫代碼就能搞定的.
      

  15.   

    同意 sqfeiyu(流星雨)            Dim myTableStyle As New DataGridTableStyle
                Dim tmpColumnCheck As New DataGridBoolColumn
                ......
     
                tmpColumnCheck.MappingName = "EftposLink"
                tmpColumnCheck.AllowNull = False
                tmpColumnCheck.Width = 120
                tmpColumnCheck.HeaderText = "EFTPOS Link"
                myTableStyle.GridColumnStyles.Add(tmpColumnCheck)           ......            dtgPaymentTypes.TableStyles.Add(myTableStyle)
      

  16.   

    先通过设机器给Datagrid添加一个BOOL列DataGridBoolColumn,
    绑定的时候如果表里面有对应列则会直接显示,没有的话手动向表里面添加这样一列
    ds.Tables[0].Columns.Add(new DataColumn("check",typeof(Boolean)));

    dgCustomer.DataSource = ds.Tables[0];
      

  17.   

    DataTable dt=DBHelper.ExecuteDataTable("select * from h_info");
    dt.Columns.Add(new DataColumn("check",typeof(Boolean))); 
    this.dataGrid1.SetDataBinding(dt,"");
      

  18.   

    http://www.syncfusion.com/FAQ/WindowsForms/FAQ_c44c.aspx
      

  19.   

    很容易,在DataStyle中加个System.Windows.Forms.DataGridBoolColumn就行了。