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);
}
}