Design Time Exception in WinForm
Please read carefully about the problem i m facing. And help me please.
I have a form class called frmMgt.
frmMgt has a protected member i.e :
Protected WithEvents DGV as DatagridView
A form class frmProjectsMgt inherits frmMgt.
Another form class frmUnitsMgt also inherits frmMgt.
When I try to write the following event handler in any of the derived class, a warning is shown immediately, and when I try to switch from code view to design view of the derived class, the designer is not visible but a strange design time exception is shown
The event is:
'(in frmProjectManagement Form)
Private Sub dgv_CellFormatting(ByVal sender As Object, ByVal e As System.Windows.Forms.DataGridViewCellFormattingEve ntArgs) Handles dgv.CellFormatting
Dim row As DataGridViewRow
For Each row In Me.dgv.Rows
If row.Cells("Status").Value = "Sold" Then
row.DefaultCellStyle.BackColor = Color.Blue
End If
Next
End Sub
'Code Ended here
----------------
The warning says:
The event cellformatting is read-only and cannot be changed
When I switch to the design view I see the following alongwith a cross (critical error) icon:
One or more errors encountered while loading the designer. The errors are listed below. Some errors can be fixed by rebuilding your project, while others may require code changes.
The event CellFormatting is read-only and cannot be changed.
Hide
at System.ComponentModel.Design.EventBindingService.E ventPropertyDescriptor.SetValue(Object component, Object value)
at System.ComponentModel.Design.Serialization.CodeDom SerializerBase.DeserializeAttachEventStatement(IDe signerSerializationManager manager, CodeAttachEventStatement statement)
at System.ComponentModel.Design.Serialization.CodeDom SerializerBase.DeserializeStatement(IDesignerSeria lizationManager manager, CodeStatement statement)
This also occur when I try to write DGV.CellContentClick event in the derived classes. But surprisingly, DGV.CellClick event in the derived class is causing no problems at all!
Further. The application causes no problems at run-time. All the problem is seen in the form designer. And the Error (warning) list does not show file name. And also tell that Line number: 0 and Column No: 0 in the errors list.
Why is this?
Why can't I write some of event handlers of a protected member of a base class in a derived class?
Regards
Hamid
|