标题:对DataGridView操作……
只看楼主
dx719823151
Rank: 1
来 自:湖北
等 级:新手上路
帖 子:17
专家分:0
注 册:2010-9-30
结帖率:100%
已结贴  问题点数:5 回复次数:1 
对DataGridView操作……
那位老兄能给我一些代码让我对DataGridView表中的数据快速进行添加、修改、删除,我想你们应该做过这方面的小型软件……
搜索更多相关主题的帖子: DataGridView 
2010-10-03 13:55
c1_wangyf
Rank: 11Rank: 11Rank: 11Rank: 11
等 级:小飞侠
威 望:7
帖 子:665
专家分:2832
注 册:2010-5-24
得分:3 
dataGridView1.Rows.Add();对行进行添加;
dataGridView1.AllowUserToAddRows = false;不显示新添加行;
dataGridView1.currentcell.value=xx;对当前单元格值的设置;
private void doDeleteEntireColumnCMD(DataGridView datagv);对单元格所在的列进行删除;
        {
            try
            {
                datagv.SelectionMode = DataGridViewSelectionMode.FullColumnSelect;
                datagv.CurrentCell.Selected = true;
                if (datagv.Columns.Count > 0)
                {

                    if (MessageBox.Show("Are you sure to delete the Entire Column?!", "Tips", MessageBoxButtons.OKCancel, MessageBoxIcon.Asterisk) == DialogResult.OK)
                    {

                        string columnname = datagv.Columns[datagv.CurrentCell.ColumnIndex].Name.ToString();
                        datagv.Columns.Remove(columnname);
                    }

                }
                else
                {
                    deleteEntireColumnToolStripMenuItem.Enabled = false;
                }
                datagv.SelectionMode = DataGridViewSelectionMode.CellSelect;
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message, "Tips", MessageBoxButtons.OK, MessageBoxIcon.Information);
            }
        }
2010-10-03 17:05



参与讨论请移步原网站贴子:https://bbs.bccn.net/thread-321913-1-1.html




关于我们 | 广告合作 | 编程中国 | 清除Cookies | TOP | 手机版

编程中国 版权所有,并保留所有权利。
Powered by Discuz, Processed in 0.073581 second(s), 8 queries.
Copyright©2004-2024, BCCN.NET, All Rights Reserved