Kfir
Kfir

Reputation: 105

Changing Checkbox Value in datagridview C# winforms

I wanted to know which is the right event to choose for making changes according to DataGridView checkbox cell value.

I want to do "A" when the checkbox is Checked and "B" when it's unchecked.

I've used CurrentCellDirtyStateChanged event and it worked partially. if i'm changing the value and then staying in the cell and change it again it causes unwanted behaviour(calling the cellclick event).

how can i prevent it?

Upvotes: 0

Views: 296

Answers (1)

Akshay Mahajan
Akshay Mahajan

Reputation: 190

Try this:

<asp:TemplateField HeaderText="View">
   <ItemTemplate>
      <asp:CheckBox ID="chkview" runat="server" AutoPostBack="true" OnCheckedChanged="chkview_CheckedChanged" />
   </ItemTemplate>
</asp:TemplateField>

and in the .cs page,

protected void chkview_CheckedChanged(object sender, EventArgs e)
{
    //Handle desired behavior 

}

Upvotes: 1

Related Questions