Using Visual Basic/VSTO, identify currently selected row of master/detail repeating table - InfoPath Dev
in

InfoPath Dev

Use our Google Custom Search for best site search results.

Using Visual Basic/VSTO, identify currently selected row of master/detail repeating table

Last post 02-11-2010 04:04 AM by Jimmy. 5 replies.
Page 1 of 1 (6 items)
Sort Posts: Previous Next
  • 09-17-2009 11:33 AM

    Using Visual Basic/VSTO, identify currently selected row of master/detail repeating table

    I'm going to simplify my question.  How, within Visual Basic can I determine the selected row of a repeating table within the InfoPath form?  It seems to me I should be able to reference the repeating table object.


    ----------------------------------------------------------------------------------------------------------------------------

    Old posting: 

    How do I go about, in Visual Basic/VSTO, identifying the currently selected row in a repeating table that's part of a master/detail relationship?  The JScript solutions I find don't seem to translate to VB.

     I'm not a strong programmer, but am comfortable in VBA and can manipulate/get properties of objects in Excel and Word.  I just can't find a correlate way within the InfoPath/VB environment.

     I've done my due diligence (about four hours worth) in trying to find the solution on my own, but have come up empty-handed. 


    Filed under:
  • 09-18-2009 04:15 PM In reply to

    Re: Using Visual Basic/VSTO, identify currently selected row of master/detail repeating table

    Hi -- a lot depends on what event you are programming to. For example, in a Changed event for a field in a repeating group, you can use e.Site (IP 2007). Can you tell us more about what you are trying to do? Are you using InfoPath 2003 or InfoPath 2007? Once you know what row is selected, what do you intend to do? Oh, and there is a Context Changed event (OnContextChange in IP 2003) that you can use, too....

    Hilary Stoupa

  • 09-18-2009 08:11 PM In reply to

    Re: Using Visual Basic/VSTO, identify currently selected row of master/detail repeating table

    If you're using the 2007 VB object model, this is the general idea.  You'll need to adjust the underlined parts to suit your solution.:

    ' Retrieve a reference to the repeating node's parent
    Dim repeatingNodeParent As XPathNavigator = _
       MainDataSource.CreateNavigator().SelectSingleNode(
    "my:myFields/my:group1", NamespaceManager)
     
    ' Get the selected position, which is stored as a property of this node.
    ' The value that corresponds to CTRL1_5 can be found in the Master table's properties in the designer
    Dim selectedPos As String = Me.MainDataSource.GetNamedNodeProperty(repeatingNodeParent, "CTRL1_5")

    Dim
    selectedPosInt As Integer

    ' Make sure it has a value that you can use before using the value
    If Integer.TryParse(selectedPos, selectedPosInt) AndAlso selectedPosInt <> 0 Then
         Dim selectedNode As XPathNavigator = _
         repeatingNodeParent.SelectSingleNode(
    "my:group2[" & selectedPosInt & "]", NamespaceManager)
         MessageBox.Show(selectedNode.OuterXml)
    Else
         ' there is nothing you can do because the view is changed or the control has no rows.
         ' show an error message or something
         MessageBox.Show("The Master/Destail control has no row selected.")
    End If

    Jimmy Rishe / Software Developer / Microsoft MVP
    Qdabra Software
  • 09-21-2009 07:08 AM In reply to

    Re: Using Visual Basic/VSTO, identify currently selected row of master/detail repeating table

     Jimmy,

    This is the solution I've been looking for.  Thanks.  I was stuck for days as to how to use the GetNamedNodeProperty method.  VB would give me a "Reference to a non-shared member requires an object reference." error.  Your code shows how to make the proper declaration
    ("Me.MainDatasource.GetNamedNodeProperty").

     And thanks to Hilary and everyone at Odabra who supports this forum.  What a great resource!

  • 02-11-2010 01:26 AM In reply to

    Re: Using Visual Basic/VSTO, identify currently selected row of master/detail repeating table

    Hi!

    I have a similar scenario and have tried multiple solutions found on the internet but all of them shows the same unwanted result.
    No matter what method i use the code returns the first row in the resulting table regardless the selected row.

    My scenario
    I have created a form that connects to a SQL-server with both queryfields and datafields is presented in a repeating table.
    When a user selects a row in the table i want to trigger code that copys the selected rows value to other fields in the form.
    Im using IP 2007 to create the forms and have to save the finished form in IP 2003 since the intended clients only have IP 2003 installed.

    Found a couple of sample codes that are supposed to give me what i want but all of them returns the first row in queryresult

    Example where i have added a button in a column

    Public Sub CTRL5_5_Clicked(ByVal sender As Object, ByVal e As ClickedEventArgs)

     

     

     

    Dim DOM As XPathNavigator = e.Source.CreateNavigator()Dim Row As String = DOM.SelectSingleNode("/my:minaFlt/my:grupp1/my:grupp2", NamespaceManager).Value

    MessageBox.Show(Row)

    End Sub

    Almost driving me crazy....crossing fingers i can get some help :)
    I thought for a while i could use the current-function which i interpet to show the selected item in list of values but i havent found any examples using it.

    Regards,
    /Micke L

     

     

     

     

    Filed under:
  • 02-11-2010 04:04 AM In reply to

    Re: Using Visual Basic/VSTO, identify currently selected row of master/detail repeating table

    You are using an absolute path here:

    /my:minaFlt/my:grupp1/my:grupp2

     But you need to use a relative path (relative to e.Source) to get at the node you want.  Are you sure that e.Source isn't already positioned at the grupp2 node that you need?

    Jimmy Rishe / Software Developer / Microsoft MVP
    Qdabra Software
Page 1 of 1 (6 items)
Copyright © 2003-2019 Qdabra Software. All rights reserved.
View our Terms of Use.