This question is specific to the XPTable control

I need to know how to programmatically pull the value of the first column of a selection made with this control.

The control in question is located here:

I just simply need to know how to get the first row value of any row selected.
LVL 18
John Gates, CISSPSecurity ProfessionalAsked:
Who is Participating?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Looking at the sample code on the website:

The TableModel also provides a Selection object that you can use to programmatically select or deselect Cells.

Is that any help?
John Gates, CISSPSecurity ProfessionalAuthor Commented:
No what I can't figure out is the following:

I have populated the control with data there are 7 columns of data for each row.  Now the user clicks the row.  In that event I want to get the value of column 0 lets say on the selected row.  I cannot seem to achieve this.  If you know how can you post a code sample to do so?

Thanks in advance,
John Gates, CISSPSecurity ProfessionalAuthor Commented:
Ok I have figured out one way to do it... Please someone out there tell me it does not have to be this way:

 Dim h As Object
        Dim i As Integer
        Dim j As String
        Dim k As String

        h = TableModel1.Rows.Count.ToString

        For i = 0 To h - 1

            'MsgBox("iterate the row")
            j = TableModel1.Rows(i).AnyCellsSelected.ToString

            If j = "True" Then


                k = TableModel1.Item(i, 0).Text().ToString()

            End If


When I use this code on the click event I get the desired value...  My question is why do I have to go through each record in the control?  Am I missing something?

CompTIA Cloud+

The CompTIA Cloud+ Basic training course will teach you about cloud concepts and models, data storage, networking, and network infrastructure.

You can add a handler to
I did it in C#
but you just need to add a handler to

this.table.TableModel.SelectionChanged +=new XPTable.Events.SelectionEventHandler(TableModel_SelectionChanged);

private void TableModel_SelectionChanged(object sender, XPTable.Events.SelectionEventArgs e)
In VB it will be like

Addhandler TableModel1.SelectionChanged, Addressof TableModel_SelectionChanged

and then your handler:

Private sub TableModel_SelectionChanged (sender as object, e as XPTable.Events.SelectionEventsArgs)
'your selection is inside 'e'
'e.newSelectedIndicies contains your selection
end sub
John Gates, CISSPSecurity ProfessionalAuthor Commented:
Can you elaborate in VB.NET? with the handler code..  Is my code above close to what needs to be there?

Well, like I said in my last message,
you could take the SelectionChanged event OR you could:

private sub ShowSelection()

for each row as XPTable.Models.Row in table.TableModel.Selections.SelectedItems
'show the item in your first column
  MessageBox.Show (row.Cells(0).Text)

probably in your case you replace table.TableModel by TabelModel1

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
John Gates, CISSPSecurity ProfessionalAuthor Commented:
Where would this line go?

Addhandler TableModel1.SelectionChanged, Addressof TableModel1_SelectionChanged

I get a syntax error anywhere I try to put that on the code page..

This line
Gives the error selections not a member of xptable...  So that snippet does not work either...

I am really frustrated with this..  So I have posted this in the VB.NET area.  Please post a working example in VB.NET and the points are yours.
John Gates, CISSPSecurity ProfessionalAuthor Commented:
I finally figured it out...  In the future you should post solutions in the thread not C#..
Uhm, I posted VB.NET code as well, didnt i? And where did I type table.selections?
I typed tableModel didnt I?
John Gates, CISSPSecurity ProfessionalAuthor Commented:
The answer I accepted was in VB correct.
Well, the sample on the website you posted was in c#..
So not very strange to assume you could read c# as well?
John Gates, CISSPSecurity ProfessionalAuthor Commented:
Why are you turning this into a debate?  I wanted a answer does not matter what the control is programmed in..  I hate C# for one simple reason...  It looks just too much like Java, period.  I can read it and convert it but why have to take the extra steps?
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Visual Basic.NET

From novice to tech pro — start learning today.