Focus can not leave the spread

Posted by: bittyboy-fp on 8 September 2017, 2:42 pm EST

  • Posted 8 September 2017, 2:42 pm EST

    hello

    everyone

     

    i use vs2010 and spread for windows forms 5 (.net 3.5) for developing.

    but recently,i have some focus problems.

    for example

    i put a spread and a textbox in the windows form.

    then i write some code like this:

     

    Private Sub FpSpread1_CellClick(ByVal sender As System.Object, ByVal e As FarPoint.Win.Spread.CellClickEventArgs) Handles FpSpread1.CellClick        

    TextBox1.Focus()    

    End Sub 

     

    when i run the program above

    i found that

    the focus can not be set to the textbox

    it still set to the spread 

    i do not know why. 

    can anyone tell me?

     

    thanks all. 

     

  • Replied 8 September 2017, 2:42 pm EST

    Hello,

    You may set   FpSpread1.FocusRenderer = Nothing when you do not want the spread to be looked like focused.

     

    Thanks,

     

  • Replied 8 September 2017, 2:42 pm EST

    sorry

     

    i have tried your method

    but it failed

    i think you misunderstood  my needs

     

    when the spread‘s cellclick event occurs

    i want to set the focus to the textbox

    so

    i use the code when i first post the help message

    but it did not work

     

    thanks anyway 

     

  • Replied 8 September 2017, 2:42 pm EST


    Hello,

    I would suggest you to cancel the default functionality of the CellClick event before setting the focus to the textbox and this would solve your problem. The code for doing the same is:

         void fpSpread1_CellClick(object sender, FarPoint.Win.Spread.CellClickEventArgs e)
            {
                e.Cancel = true;
                textBox1.Focus();
                fpSpread1.FocusRenderer = null;
            } 

    Thanks,

    Manpreet Kaur.

  • Replied 8 September 2017, 2:42 pm EST

    thanks very much

    it works

     

    but

    i still don't know why 

    ... 

  • Replied 8 September 2017, 2:42 pm EST

    Hello,

    CellClick event sets the focus to the cell from where it has been called, when the CellClick event is fired then we need to cancel it in order to cancel the default functionality of that particular event and perform our own functionality. If we will not set the Cancel property of the CellClick event to false then it will it will first set the focus to the spread cell, then to TextBox and since the event is not completed yet, hence the focus will be again on spread i.e. why you aren't able to see the blinking cursor in the textbox.

    Thereon, setting the FocusRenderer to null just prevent the spread cell form getting highlighted and every-time the focus would be on TextBox.

    Thanks.

     

  • Replied 8 September 2017, 2:42 pm EST


    ok


    thank you


    Yes

  • Replied 8 September 2017, 2:42 pm EST

    ok

    thanks

    i will try it tomorrow and tell you the result

    because i don't have the develop environment at home

    :p 

     

Need extra support?

Upgrade your support plan and get personal unlimited phone support with our customer engagement team

Learn More

Forum Channels