TextBox OnGotFocus Event - InfoPath Dev
in

InfoPath Dev

TextBox OnGotFocus Event

Last post 10-10-2005 06:39 AM by Matt Faus. 5 replies.
Page 1 of 1 (6 items)
Sort Posts: Previous Next
  • 10-06-2005 04:24 AM

    TextBox OnGotFocus Event

    Hi,

    i have a repating section in which i have placed one text box,
    and i have one more textbox on form which is outside of repeater control.

    now at runtime if i insert new entries of repeating section (in each entry, i enter some data in textbox)

    now i want, when i move my cursor to any of the textbox in repeating section, the content of the textbox should be reflected in textbox which is outside of repeating section.

    Thanks & Regards,
    Santosh.



    Thanks & Regards
    Santosh
  • 10-06-2005 05:42 AM In reply to

    Re: TextBox OnGotFocus Event

    You may have to add a button click to get the functionality you are looking for. From what I understand, the user will

    - enter a value into a textbox
    - visually select a row in a repeating table
    - then the user would have to press a button to move the data to the selected row

    I have not found that InfoPath does not have as many events to hook into as in over places.

    So the key here is when the button is clicked, you have the index of the selected row. I wrote a method like the one below to get the current row selected in a repeating table. If I remember correctly, the repeating table had to be set up as Master table for this to work.

    Function GetSelectedItemsIndex()

    Dim iRow
    Dim iItemCount

    iRow = 1
    iItemCount = XDocument.DOM.selectNodes("//my:Item").length

    'check the current part row count
    If iItemCount = 0 Then
    iRow = 0
    Else
    'we know there is at least one row
    iRow = 1

    'Call to the dom and get the current selected row.
    '-1 will be returned if there is any error trying to
    'locate the current row.
    If iItemCount > 1 Then
    iRow = CInt(XDocument.GetNamedNodeProperty( _
    XDocument.DOM.selectSingleNode("my:Items"), "CTRL408", -1))
    End If

    End If

    GetSelectedItemsIndex = iRow

    End Function
    Jason
    http://www.k2distillery.com/
  • 10-06-2005 10:04 PM In reply to

    Re: TextBox OnGotFocus Event

    vt_asparagus Thanks for your reply,

    one of our member (MFaus) has given me the code to select a particular node of repeating section and delete that

    var node = XDocument.DOM.selectSingleNode( "my:myFields/my:group1/my:group2[my:id = 3]" );
    // remove single row from table
    node.parentNode.removeChild( node );

    but here i need to provide the value of control (my:id = 3, where id is a textbox control in repeating section). my problem is how to set this value at runtime (i.e. i want to delete only selected node)

    to achieve this i was thinking to have one textbox outside repeating section and, i'll link its value to the textbox in repeating section (using rules), and then write the above code on delete button click and concatinate the value from the textbox which is outside repeating section. but this dosent help me to achieve the functionality.

    Please help.

    Thanks & Regards,
    Santosh.
  • 10-07-2005 05:39 AM In reply to

    Re: TextBox OnGotFocus Event

    Ok. Using both my post, and the code you found, I would try something like:

    Dim iSelectedIndex
    Dim objSelectedNode
    iSelectedIndex = GetSelectedPartsIndex()
    objSelectedNode = XDocument.DOM.selectSingleNode("//Item[" & CStr(iSelectedIndex) & "]")
    objSelectedNode.parentNode.removeChild(objSelectedNode)

    In vbscript but you should be able to translate. Hope this helps.
    Jason
    http://www.k2distillery.com/
  • 10-10-2005 04:35 AM In reply to

    Re: TextBox OnGotFocus Event

    hi vt_asparagus,

    Thanks very much for Reply
    i m not able to understand following line

    iRow = CInt(XDocument.GetNamedNodeProperty( _
    XDocument.DOM.selectSingleNode("my:Items"), "CTRL408", -1))

    what are (my:Items & CTRL408) ?
    if we have my:myFields/my:group1/my:group2/my:id,
    where id is textbox in repeating section my:group2, what do i need to provide in the statement which you have given for GetNamedNodeProperty


    Thanks & Regards
    Santosh
  • 10-10-2005 06:39 AM In reply to

    Re: TextBox OnGotFocus Event

    Not sure if I'm following exactly what you want, but look at these tutorials. They helped me A LOT.

    http://www.infopathdev.com/howto/tutorials/default.aspx?s=Repeating%20Tables

    ---------------
    Matt Faus
    Matt Faus / Microsoft InfoPath MVP
    Qdabra® Software / Streamline data gathering to turn process into knowledge
Page 1 of 1 (6 items)
Copyright © 2003-2019 Qdabra Software. All rights reserved.
View our Terms of Use.