Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
Home
DiscussionsAccessExcelInfoPathOutlookPowerPointPublisherWord
DirectoryUser Groups
Related Topics
Outlook ExpressInternet ExplorerWindowsMS Server ProductsMore Topics ...

MS Office Forum / General MS InfoPath Questions / August 2005

Tip: Looking for answers? Try searching our database.

set focus to textbox that hides/unhides

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
chloraphil - 04 Aug 2005 18:46 GMT
I currently have a textbox that is hidden unless "Other" is selected from a
listbox.  This functionality is implemented in Conditional Formatting.

I want to set focus to this textbox.  SelectText doesn't work b/c the code
runs before the rules, therefore SelectText fails b/c the textbox isn't
user-selectable.

Ideas?
Greg Collins [InfoPath MVP] - 04 Aug 2005 23:21 GMT
Try placing the code into the OnContextChange event handler.
This was the only way I could get it to work with this example:

Fully Editable Drop-down List Box
http://www.infopathdev.com/downloads/free/default.aspx?i=0672a57e920b4771b62b1c2
2d5bd314d


Signature

Greg Collins [InfoPath MVP]
Please visit: http://www.InfoPathDev.com

I currently have a textbox that is hidden unless "Other" is selected from a
listbox.  This functionality is implemented in Conditional Formatting.

I want to set focus to this textbox.  SelectText doesn't work b/c the code
runs before the rules, therefore SelectText fails b/c the textbox isn't
user-selectable.

Ideas?
chloraphil - 05 Aug 2005 14:41 GMT
Here's my code, which is a bit of a hack, but works: (my apologies if it's
not very readable - it reads well in my VS IDE

public void OnContextChange(DocContextChangeEvent e)
{
if (e.Type == "ContextNode")
{
   if (e.Context.nodeName.ToString().Equals("my:CI") && //correct context?
   
(thisXDocument.DOM.selectSingleNode("my:CI/my:Notifications").text.Equals("Other")) && // and "Other" is selected   
   
((thisXDocument.DOM.selectSingleNode("my:CI/my:other").text.Equals("Enter
Notification Type...")) || // and no changes have been made
   
(thisXDocument.DOM.selectSingleNode("my:CI/my:other").text.Equals(""))))// or
the user just deleted "Enter Notification Type"
{    //then set focus to the 'other' textbo
    thisXDocument.View.SelectText(thisXDocument.DOM.selectSingleNode("my:CI/my:other"),Type.Missing);
}
return;
}
}
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.