locked
onMouseClick comboBox Cell in dataGridView,throw null reference exception RRS feed

  • Question

  • I have a table display in datagridview with comboBox columns.

    When I try 1st times change of the comboBox value,it works fine. However, If I try it again 2nd times,just onMouseClick on comboBox,then it throw error. I failed to trap  the error within try{} catch{} block,but show error at the point application run.

    Application.Run(new Form1());

    Noted that I failed to do "step-into" anymore before editingComboBox_SelectedIndexChanged(),so i unable to know which part of reference value is null. I suspect this is a bug in dataGridView control,,which needs to be addresses by Microsoft. Might be I'm wrong...


    System.NullReferenceException was unhandled
      Message=Object reference not set to an instance of an object.
      Source=System.Windows.Forms
      StackTrace:
           at System.Windows.Forms.DataGridViewComboBoxCell.InitializeEditingControl(Int32 rowIndex, Object initialFormattedValue, DataGridViewCellStyle dataGridViewCellStyle)
           at System.Windows.Forms.DataGridView.InitializeEditingControlValue(DataGridViewCellStyle& dataGridViewCellStyle, DataGridViewCell dataGridViewCell)
           at System.Windows.Forms.DataGridView.BeginEditInternal(Boolean selectAll)
           at System.Windows.Forms.DataGridViewComboBoxCell.OnMouseClick(DataGridViewCellMouseEventArgs e)
           at System.Windows.Forms.DataGridView.OnCellMouseClick(DataGridViewCellMouseEventArgs e)
           at System.Windows.Forms.DataGridView.OnMouseClick(MouseEventArgs e)
     
     

    I manage re-produce same error on demo application that I upload to skydrive. Hope someone have a looks and give me advice. Welcome to download form the link below. thanks

    demoDataGridView

    Wednesday, March 19, 2014 6:27 AM

Answers

  • Hello

    You are posting the same issue second time right.?

    Well, I looked into your code and made corrections, you can find project here

    • Marked as answer by ocibala Wednesday, March 19, 2014 4:30 PM
    Wednesday, March 19, 2014 2:04 PM

All replies

  • Hello

    You are posting the same issue second time right.?

    Well, I looked into your code and made corrections, you can find project here

    • Marked as answer by ocibala Wednesday, March 19, 2014 4:30 PM
    Wednesday, March 19, 2014 2:04 PM
  • Hello

    You are posting the same issue second time right.?

    Well, I looked into your code and made corrections, you can find project here

    Hi 

    Yes,I post it second time. Thank for your corrections.

    Wednesday, March 19, 2014 4:30 PM