如题,我想规定某列为按钮列,但是可以添加多个按钮,也可以为空...如何实现?注意,是C# winform中的datagridview。

解决方案 »

  1.   

                            //將非護理問題的button歷史評值屏蔽掉
                            DataGridViewCell cell = new DataGridViewTextBoxCell();
                            cell.Style.BackColor = Color.Wheat;
                            //cell.ReadOnly = true;
                            cell.Value = "N";
                            cell.Style.BackColor = Color.White;
                            dataGridView1.Rows[k].Cells["Column14"] = cell;
                            dataGridView1.Rows[k].Cells["Column14"].Style.ForeColor = Color.White;
                            dataGridView1.Rows[k].Cells["Column14"].Style.SelectionBackColor = Color.White;
                            dataGridView1.Rows[k].Cells["Column14"].Style.SelectionForeColor = Color.White;这个是我经常使用的屏蔽的方法,你试一下吧
      

  2.   

    就是把某个buttoncell转换成textcell就可以了
      

  3.   

    @muyebo
    可能我说得不是很清楚,我要实现的是一个单元格中有多个固定大小的按钮
      

  4.   

    http://www.tctl.com.cn/accp/1490/1496/114320.html
      

  5.   

    根据格子的位置往上贴的方法可以实现, 
                   timepicker dtpLapseDate = new timepicker();
                   Rectangle cellrect = dataGridView1.GetCellDisplayRectangle(ColumnIndex, RowIndex, true);
                    dtpLapseDate.Height = cellrect.Height;
                    dtpLapseDate.Width = cellrect.Width;
                    dtpLapseDate.Top = cellrect.Top + dataGridView1.Top;
                    dtpLapseDate.Left = dataGridView1.Left + cellrect.Left;
                    dtpLapseDate.Visible = true;
                    dtpLapseDate.BringToFront();这是添加一个,添加多个也这样,不过麻烦些
    可能还有更好的办法,你等等看
      

  6.   

    将列的属性设为Button就可以了