0

hi there,

i have a code for the above mentioned property below,when i click a value from the datagridview combo box column the for loop runs 2 times y is that??? what do i have to do for the loop to run once.

thanxxxxxxx

private void dgvSubContract_CurrentCellDirtyStateChanged(object sender, EventArgs e)
        {
            if (dgvSubContract.CurrentCell == null)
                return;
            if (dgvSubContract.CurrentCell.ColumnIndex == 0)
            {
                dgvSubContract.CommitEdit(DataGridViewDataErrorContexts.Commit);

                if ((dgvSubContract.CurrentCell.Value != null))
                {
                    int r = dgvSubContract.SelectedCells[0].RowIndex;
                    String subName = dgvSubContract.Rows[r].Cells[0].Value.ToString();
                    String[] a = new String[4];
                    a = m.getSudDetails(subName);
                    for(int i = 0; i< 4; i++)
                    {   
                        MessageBox.Show(a[i].ToString());
                    }
                    return;
                }
               return;
            }




        }
2
Contributors
2
Replies
5
Views
7 Years
Discussion Span
Last Post by judithSampathwa
0

Posibly because you are comiting the changes and thus changing the CellDirty state.
Test the datagrid IsCurrentCellDirty before executing the commit.

Edited by nick.crane: n/a

0

Posibly because you are comiting the changes and thus changing the CellDirty state.
Test the datagrid IsCurrentCellDirty before executing the commit.

w@ do u mean, i didn't get it, do i have to do something before line 7 in the post that i have posted previously.

thanxxxxxxxxx

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.