المساعد الشخصي الرقمي

مشاهدة النسخة كاملة : Problems with getting UserDeletingRow event to work.



C# Programming
09-24-2009, 05:00 PM
When i delete the row in a datagridview, it does not act accordingly with my UserDeletingRow event. I am clueless about what is wrong with my codes or why it does not work. Anyone knows the problem? Thanks!



// dataGridView1
//
this.dataGridView1.AllowUserToAddRows = false;
this.dataGridView1.AutoSizeColumnsMode = System.Windows.Forms.DataGridViewAutoSizeColumnsMode.AllCells;
this.dataGridView1.ColumnHeadersHeightSizeMode = System.Windows.Forms.DataGridViewColumnHeadersHeightSizeMode.AutoSize;
this.dataGridView1.******** = new System.Drawing.Point(15, 70);
this.dataGridView1.MultiSelect = false;
this.dataGridView1.Name = "dataGridView1";
this.dataGridView1.ReadOnly = true;
this.dataGridView1.Size = new System.Drawing.Size(92, 173);
this.dataGridView1.TabIndex = 72;
this.dataGridView1.UserDeletingRow += new System.Windows.Forms.DataGridViewRowCancelEventHandler(this.dataGridView1_UserDeletingRow);


private void delete1_Click(object sender, EventArgs e)
{
textBox1.Text = dataGridView1.Rows[dataGridView1.CurrentCell.RowIndex].Cells[dataGridView1.CurrentCell.ColumnIndex].Value.ToString();
dataGridView1.Rows.Remove(dataGridView1.CurrentRow);

}

private void dataGridView1_UserDeletingRow(object sender, DataGridViewRowCancelEventArgs e)
{
textBox4.Text = "yeah";

}