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
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.
I am setting the IsInEditMode property from within the ultraToolbarsManager1_ToolValueChanged event. I have a combo on the toolbar that,depending on what is selected in the combo by the user (in the ToolValueChanged event), will set different text values in a TextBoxTool on the same toolbar, set focus to it (the TextBoxTool) and place the caret in the second position in the text.
Just tried it again, with the same results. I also tried some code I found elsewhere (I think onyour site or documentation) that does the following:
public static void PutToolInEditMode(ToolBase tool) { // only an editor tool can be put into edit mode. we need to // also check for placeholder tools in case this is the mdi parent // form's toolbarsmanager and the child toolbarmanager has the // editor tool if (tool is EditorToolBase || tool is MdiMergePlaceholderTool) { // walk over all the instances of this tool - i.e. all of // the tools with the same key on different toolbars and // menus foreach (ToolBase toolInstance in tool.SharedProps.ToolInstances) { // access the underlying tool in case this is an // place holder tool EditorToolBase editorTool = toolInstance.UnderlyingTool as EditorToolBase; // if the tool is currently in view and can be activated // then we can try to put it into edit mode if (null != editorTool && editorTool.CanActivate && editorTool.VisibleResolved) { // try to put the tool into edit mode editorTool.IsInEditMode = true; break; } } } }
Then I call PutToolInEditMode(txtSrchFor) instead of txtSrchFor.IsInEditMode. Interestingly, when I step to the line that says If(null != EditorTool && EditorTool.CanActivate ....), the CanActivate property is false, and the function will not set IsInEditMode to true. Is something checking this value (CanActivate) inside IsInEditMode? I can't think of any other events that are causing a problem...
I tried setting IsInEditMode in the ToolValueChanged event fired by a combo box value changing and again it worked fine, so it might be a bug which only occurs when the toolbars manager is in a specific state. I would recommend submitting the issue to the support group: http://es.infragistics.com/gethelp.
I looked through the CanActivate property getter and it looks like it should only return False if the tool is disabled or hidden by a merge.
Hi There.....
The info here is mindblowingly useful and i could resolve many of my issues by just searching the forums.....
Keep the Great Work Going.......