Highlighting Current Textbox - InfoPath Dev
in

InfoPath Dev

Highlighting Current Textbox

Last post 12-03-2008 06:49 AM by potso. 6 replies.
Page 1 of 1 (7 items)
Sort Posts: Previous Next
  • 12-02-2008 11:37 AM

    • potso
    • Not Ranked
    • Joined on 05-21-2008
    • Posts 11

    Highlighting Current Textbox

    Could someone please help me with this. I want whatever textbox has the focus of the cursor to be highlighted. so if i a user tabs through the textboxes they can easily see which one they are in. Please let me know. Thanks!

  • 12-02-2008 12:03 PM In reply to

    Re: Highlighting Current Textbox

    Hi potso,

    Greg wrote a blog entry on this. Please read it by clicking here.

    Hope it helps!

    Ernesto Machado
    Qdabra® Software/ InfoPathDev.com
    The InfoPath Experts – Streamline data gathering to turn process into knowledge.™


  • 12-02-2008 12:17 PM In reply to

    • potso
    • Not Ranked
    • Joined on 05-21-2008
    • Posts 11

    Re: Highlighting Current Textbox

    I have inserted the code and i seem to still be getting errors. I have errors in following places. they are bolded

     

     

    var oActiveContext = null;

    ' The following function handler is created by Microsoft Office InfoPath. Do not

    ' modify the type or number of arguments.

    <InfoPathEventHandler(EventType:=InfoPathEventType.OnContextChange)> _

    Public Sub OnContextChange(ByVal e As DocContextChangeEvent)

     

    if (eventObj.Type != "ContextNode" || eventObj.IsUndoRedo)return;

    Try

    {

    XDocument.SetNamedNodeProperty(oActiveContext, "active", "0");

    }

    catch(e){}

     

     

     

    oActiveContext = eventObj.Context;

    XDocument.SetNamedNodeProperty(oActiveContext, "active", "1");

     

    Return

    End If

    End Sub

    End Class

  • 12-02-2008 12:52 PM In reply to

    Re: Highlighting Current Textbox

    I believe the sample in the blog post is in jscript -- it looks as if you are using VB.NET. You may want to change the programming language in your form to JScript, then try the sample.

    To change the programming language, you'll need to go to Tools/Form Options. Select Programming and click the Remove Code button. Then change the language to JScript.

    Hilary Stoupa

  • 12-02-2008 05:33 PM In reply to

    Re: Highlighting Current Textbox

    This code should do the trick in VB.NET:

    Dim oActiveContext As XPathNavigator

    Public Sub FormEvents_ContextChanged(ByVal sender As Object, ByVal e As ContextChangedEventArgs)
         If (e.ChangeType = "ContextNode") Then
              Try
                   MainDataSource.SetNamedNodeProperty(oActiveContext, "active", "0")
              Catch
              End Try
              oActiveContext = e.Context
              MainDataSource.SetNamedNodeProperty(oActiveContext,
    "active", "1")
              Return
         End If
    End Sub

    Jimmy Rishe / Software Developer / Microsoft MVP
    Qdabra Software
  • 12-02-2008 05:46 PM In reply to

    Re: Highlighting Current Textbox

    Ah, I see. You're using InfoPath 2003.  In that case, this should work:

    Dim oActiveContext As IXMLDOMNode

    <InfoPathEventHandler(EventType:=InfoPathEventType.OnContextChange)> _
    Public Sub FormEvents_OnContextChange(ByVal e As DocContextChangeEvent)
         If (e.Type = "ContextNode" And Not e.IsUndoRedo) Then
              Try
                   thisXDocument.SetNamedNodeProperty(oActiveContext, "active", "0")
              Catch
              End Try

              oActiveContext = e.Context
              thisXDocument.SetNamedNodeProperty(oActiveContext,
    "active", "1")
              Return
         End If
    End Sub

    Jimmy Rishe / Software Developer / Microsoft MVP
    Qdabra Software
  • 12-03-2008 06:49 AM In reply to

    • potso
    • Not Ranked
    • Joined on 05-21-2008
    • Posts 11

    Re: Highlighting Current Textbox

    Thanks! The code seems to be correct. But when i try to run the form i get the following error in infopath.

     

    InfoPath cannot open the selected form because of an error in the form's code.
    Index refers beyond end of list

     

     

Page 1 of 1 (7 items)
Copyright © 2003-2019 Qdabra Software. All rights reserved.
View our Terms of Use.