CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 2 of 2
  1. #1
    Join Date
    Jul 2009
    Posts
    2

    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.

  2. #2
    Join Date
    Sep 2009
    Posts
    1

    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
  •  





Click Here to Expand Forum to Full Width

Featured