Button Click - Prevent Lost Focus from currently focused textfield to clicked button? RRS feed

  • Question

  • Instead of a modified SIP - I've created chuncky finger-friendly number buttons in a panel.

    When a textfield onFocus is triggered the panel is made visible - on textfield lostFocus the panel is made non visible.

    However, when I click a button the textfield loses focus and the button gets focus.

    Like a typical keyboard button on SIP - I want a button that does not get focus and stops the textfield from losing  focus.

    In the full framework this is possible - is it possible with the compact framework?

    Does anybody have some example code in vb please?

    Many thanks


    Monday, April 23, 2012 10:31 AM

All replies

  • Hello,

    You can try textbox.Foucs() when you click the button, so that the textfield can get the focus again.

    Best regards,

    Jesse Jiang [MSFT]
    MSDN Community Support | Feedback to us

    Tuesday, April 24, 2012 7:52 AM
  • Thanks Jesse - I've already done that now anyway - on getFocus of the textbox I grab the sender and after adding the button character I focus it back and set the cursor to the last position.


    focusedContol.SelectionStart = focusedContol.Text.Length

    Ideally I'd like to override the button focus as with this method I have to remove the lostFocus of the textbox which hides the panel and deal with it seperately. Otherwise as soon as I click the custom button it kicks in lost focus on the textbox and immediatly hides the panel.

    I have got round it - but if someone knows if I can make a button that does not fire a focus it cuts the code down and makes it much more efficient.

    Thanks for offering a work arround though Jess


    Tuesday, April 24, 2012 8:01 AM