I have a method in VB.Net that calls button of form:
Private Sub BUTTON_CAL( _
ByVal frm As Object, ByVal e As System.Windows.Forms.KeyEventArgs)
If e.KeyCode = Keys.A AndAlso e.Modifiers = Keys.Control Then
If frm.AddButton.Enabled = True Then Call frm.AddButton.PerformClick()
e.SuppressKeyPress = True
End if
End Sub
I have converted this code into c#
public static void BUTTON_CAL(object frm, System.Windows.Forms.KeyEventArgs e) {
if(e.KeyCode==Keys.A&&e.Modifiers==Keys.Control) {
if(frm.AddButton.Enabled==true) {
frm.AddButton.PerformClick();
}
e.SuppressKeyPress=true;
}
}
in C#.Net I am getting the error
'object' does not contain a definition for AddButton' and no extension method 'AddButton' accepting a first agument of type 'object' could be found(are you missing a using directive or an assembly reference?)
frmto it's actual type. Show where you call this method.BUTTON_CAL(object frm ...OPTION STRICT onin VB.NET as well. Also,Callis a redundant statement.frmasdynamicinstead of asobject.