Click here to Skip to main content
15,895,813 members
Please Sign up or sign in to vote.
4.00/5 (1 vote)
See more:
I have written this code....!

C#
private void dgvCust_CellDoubleClick(object sender, DataGridViewCellEventArgs e)
{
    try
    {
        if (IsList)
        {
            if (dgvCust.SelectedRows.Count >= 0)
            {
                mCustomerNo = dgvCust.Rows[e.RowIndex].Cells["No"].Value.ToString();
                OnCustomerChanged(mCustomerNo);
                this.Dispose();
            }
        }
        else
        {
            mNo = dgvCust.Rows[e.RowIndex].Cells["No"].Value.ToString();
            if (mNo != "")
            {
                FrmCustomerDetail objFrmCustDetail = new FrmCustomerDetail();
                FrmCustomerDetail.CustNo = mNo;
                FrmCustomerDetail.isLoading = true;
                objFrmMain.CheckOpened(objFrmCustDetail);
                objFrmMain.OpenForm(objFrmCustDetail, this);
            }
        }
    }
    catch (Exception Ex)
    {
        MessageBox.Show(Ex.Message);
    }
}



The selection mode of dgv is : RowHeaderSelect

When at runtime i doubleclick on dgv its not working...!
After third time clicking it works....!
I dont know where i am going wrong...!

Kindly Help!!!!
Posted
Updated 21-Feb-11 1:07am
v2

1 solution

I'm not sure either, but that is some very odd code: why are you trying to Dispose your form?

I suggest that you start by placing a breakpoint on the "{" after "try" and step through.
 
Share this answer
 
Comments
Prasad131 21-Feb-11 6:47am    
Thanks for u interest....!

I have used this form as a master form to pick data....to some other form....!
I have tried as u said ...by debugging....!

It fires after double clicking....!
But not at first time clicking after 3rd time...!
So where i am going wrong....?

Kindly Do Reply....!
OriginalGriff 21-Feb-11 7:01am    
I can't help thinking that you are doing something very, very wrong all the way down here.
You seem to be using static properties to transfer info into a new instance of a form?
And then checking back to another form with static methods to display it?
And at some point disposing what you do have.
I can't help thinking that you need to sit down and work out what you are trying to do: and getting rid of the static methods and properties in favour of using the instances you already have.
I suspect that the confused / confusing way you are doing this is responsible for the odd way things are behaving.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900