Your Privacy Matters: We use our own and third-party cookies to improve your experience on our website. By continuing to use the website we understand that you accept their use. Cookie Policy
195
Setting SelectionLength on TextBoxTool
posted

I am trying to set the SelectionLength and SelectionStart on a TextBoxTool object that is in a toolbar, in essence setting the caret to the 2nd place in the textbox. Trouble is, I can't do that bexause I get an error "must be in edit mode". When I try to set the edit mode as in :

                 TextBoxTool txtSrchFor = ultraToolbarsManager1.Toolbars["ToolbarMain"].Tools["SrchFor"] as TextBoxTool;
               
                txtSrchFor.IsInEditMode = true;

nothing happens. The IsInEditMode property remains false.

 How do you set the focus to a Tool on a toolbar and place the caret (cursor?) in an arbitrary place?

 

TIA

    

Parents
  • 44743
    posted

    I tried to reproduce this in a sample and I was able to set the SelectionLength and SelectionStart with the following code:

    TextBoxTool txtSrchFor = ultraToolbarsManager1.Toolbars[ "ToolbarMain" ].Tools[ "SrchFor" ] as TextBoxTool;
    txtSrchFor.IsInEditMode = true;
    txtSrchFor.SelectionStart = 1;
    txtSrchFor.SelectionLength = 3;

    In what event are you setting the IsInEditMode property? Its possible something is taking activation from the TextBoxTool after your event handler returns so it is exiting edit mode.

Reply Children