|
-
September 16th, 2009, 05:09 PM
#1
Buton Column in Datagrind Windows Forms
Hi ,
I need to develop a windows application using .net 1.1.
In some form i want Datagrid with button column for each row on click of each button i want to delete that particular row.
Can any please help me on doing it.
-
September 29th, 2009, 03:34 AM
#2
Re: Buton Column in Datagrind Windows Forms
Hi.
Maybe this can help you:
- add a new DataGridView component on form
- add your columns, the first being a DataGridViewButtonColumn (ColumnType property)
- override CellClick event of the DataGridView
Code:
private void dataGridView1_CellClick(object sender, DataGridViewCellEventArgs e)
{
if ((e.ColumnIndex == 0) && (e.RowIndex != dataGridView1.Rows.Count-1)) //if clicked on new row
if (MessageBox.Show("Are you sure you want to delete row " + e.RowIndex.ToString() + " ?", "Question", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.Yes)
{
//delete current row
dataGridView1.Rows.RemoveAt(e.RowIndex);
}
}
With regards,
Dan Fat
Tags for this Thread
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|