请问在Winform中dataGridView应该怎样设置?功能描述:
dataGridView绑定好数据表后,显示表中的记录。然后,在每行记录的最后加两个按钮,分别是“修改”和“删除”。当点击“修改”按钮后,可修改该行记录的数据,同时“修改”按钮变为“保存”按钮。点击“保存”按钮,保存修改后的数据到数据库。当点击“删除”按钮时,删除表中的本条记录。问题一:这样的功能应该怎样实现?要用到“dataGridView”的那些属性和方法?问题二:能给个实例、类、源代码参考下吗?

解决方案 »

  1.   

    DataGridView增删改查功能的实现
    http://download.csdn.net/source/2559075下载看下代码就行了,这个功能挺简单。
      

  2.   

    http://download.csdn.net/source/2559075
    同意楼上
      

  3.   

    想实现gridview中效果,自定义datagridview
      

  4.   

    添加DataGridViewButtonColumn列。 逻辑自己写~
      

  5.   

    1.和datagridview没有太大关系,主要是对数据库进行操作。datagridview只是起到绑定资源的作用。
    2.类似于一下的思路:void btn(object sender,eventargs e)
    {
        if(btn.Text=="修改")
           btn.Text="保存"; 
           //To modify
        else
            btn.Text="修改";
           //To conserve 
    }
      

  6.   

    学习下,感觉DataGridview自身肯定是不行了,自己写逻辑代码吧,
      

  7.   


             //判断制卡按钮是否显示
            private void dataGridView1_RowPostPaint(object sender, DataGridViewRowPostPaintEventArgs e)
            {
                using (SolidBrush b = new SolidBrush(dataGridView1.RowHeadersDefaultCellStyle.ForeColor))
                {
                    e.Graphics.DrawString((e.RowIndex + 1).ToString(System.Globalization.CultureInfo.CurrentCulture), dataGridView1.DefaultCellStyle.Font, b, e.RowBounds.Location.X + 15, e.RowBounds.Location.Y + 4);
                    
                    DataGridViewDisableButtonCell buttonCell = (DataGridViewDisableButtonCell)dataGridView1.Rows[e.RowIndex].Cells["Buttons"];                if (dataGridView1.Rows[e.RowIndex].Cells["ColumnFabrication"].Value.ToString().Equals("是"))
                    {
                        buttonCell.Value = "已制卡";                    buttonCell.Enabled = false;
                    }
                    else
                    {
                        buttonCell.Value = "制卡";
                        buttonCell.Enabled = true;
                    }
                }
            }