Conversion From VB
-
I am converting some code written by someone else in VB(.NET?) to Visual C#. I have figured out most of the weird language, but I am stuck on one problem. Here is the VB code (you may recognize it from MSDN):
Private Sub ConfigureContextMenu(ByVal sender As Object, ByVal e As EventArgs) Handles MyBase.Popup Dim ctl As TextBox = CType(Me.SourceControl, TextBox) MenuItems .Enabled = ctl.CanUndo MenuItems(7).Enabled = (ctl.SelectedText <> ctl.Text) MenuItems(2).Enabled = (ctl.SelectionLength > 0) ' cut ... (continues)
How do I translate the usage of theHandles
keyword in VB to C#. I know there is no handles keyword. Thanks in advance for any help, Josh Koppang There's a fine line between confidence and arrogance. -
I am converting some code written by someone else in VB(.NET?) to Visual C#. I have figured out most of the weird language, but I am stuck on one problem. Here is the VB code (you may recognize it from MSDN):
Private Sub ConfigureContextMenu(ByVal sender As Object, ByVal e As EventArgs) Handles MyBase.Popup Dim ctl As TextBox = CType(Me.SourceControl, TextBox) MenuItems .Enabled = ctl.CanUndo MenuItems(7).Enabled = (ctl.SelectedText <> ctl.Text) MenuItems(2).Enabled = (ctl.SelectionLength > 0) ' cut ... (continues)
How do I translate the usage of theHandles
keyword in VB to C#. I know there is no handles keyword. Thanks in advance for any help, Josh Koppang There's a fine line between confidence and arrogance.Josh, I am unfamiliar with the rest of the code...so please take this with the appropriate grain of salt. It looks like you want your method (ConfigeContextMenu) to handle the Popup event on MyBase (a ContextMenu?) In C# you do would something like:
MyBase.Popup+=new EventHandler(ConfigContextMenu);
Bill