Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. C#
  4. Conversion From VB

Conversion From VB

Scheduled Pinned Locked Moved C#
helpcsharpquestion
2 Posts 2 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • J Offline
    J Offline
    Josh Koppang
    wrote on last edited by
    #1

    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 the Handles 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.

    B 1 Reply Last reply
    0
    • J Josh Koppang

      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 the Handles 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.

      B Offline
      B Offline
      Bill Dean
      wrote on last edited by
      #2

      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

      1 Reply Last reply
      0
      Reply
      • Reply as topic
      Log in to reply
      • Oldest to Newest
      • Newest to Oldest
      • Most Votes


      • Login

      • Don't have an account? Register

      • Login or register to search.
      • First post
        Last post
      0
      • Categories
      • Recent
      • Tags
      • Popular
      • World
      • Users
      • Groups