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;
            }




        }

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

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

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.