Results 1 to 3 of 3

Thread: [RESOLVED] Weird Bug on menu clicks

  1. #1

    Thread Starter
    Fanatic Member BenJones's Avatar
    Join Date
    Mar 2010
    Location
    Wales UK
    Posts
    814

    Resolved [RESOLVED] Weird Bug on menu clicks

    Hi have this strange bug or something I duno how else to put it heres the problum.
    I add a menu strip to a form and a text box I add an menu item anything for example Cut I add the code

    on click event TextBox1.Cut()

    Now what this does are you can see is cut the text in a text box, so if I select all text click the item the text get's cut
    the problum is when I click in the textbox the cursor has gone.

    But now if I was to put the same code into a command button and do the same the cursor is there it makes no sence.
    any ideas?

  2. #2
    PowerPoster dunfiddlin's Avatar
    Join Date
    Jun 2012
    Posts
    8,245

    Re: Weird Bug on menu clicks

    Er ... it should be the other way round. A menu item can't take focus so the cut would leave the cursor in the text box ready for whatever without any further action necessary. A button can take focus and therefore the cursor is absent after executing the command from a button. In no circumstances can the cursor fail to appear if you click inside the text box.
    As the 6-dimensional mathematics professor said to the brain surgeon, "It ain't Rocket Science!"

    Reviews: "dunfiddlin likes his DataTables" - jmcilhinney

    Please be aware that whilst I will read private messages (one day!) I am unlikely to reply to anything that does not contain offers of cash, fame or marriage!

  3. #3

    Thread Starter
    Fanatic Member BenJones's Avatar
    Join Date
    Mar 2010
    Location
    Wales UK
    Posts
    814

    Re: Weird Bug on menu clicks

    ok I think I found a workaround by setting focus to the main form never had to do this in VB6 or anyother lanuage I used it always left the cart were it was strange.

    Code:
        Private Sub mnuCut_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles mnuCut.Click
            txtCode.Cut()
            Me.Focus()
        End Sub
    Last edited by BenJones; Jan 27th, 2013 at 04:33 PM.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width