Link to home
Start Free TrialLog in
Avatar of John Gates, CISSP, CDPSE
John Gates, CISSP, CDPSEFlag for United States of America

asked on

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:

http://www.codeproject.com/cs/miscctrl/XPTable.asp

I just simply need to know how to get the first row value of any row selected.
Avatar of PockyMaster
PockyMaster
Flag of Netherlands image

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?
Avatar of John Gates, CISSP, CDPSE

ASKER

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,
-D-
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

                'MsgBox(j)

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


            End If


        Next

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?

-D-
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
Can you elaborate in VB.NET? with the handler code..  Is my code above close to what needs to be there?

ASKER CERTIFIED SOLUTION
Avatar of PockyMaster
PockyMaster
Flag of Netherlands image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
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
Table.Selections.SelectedItems
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.
I finally figured it out...  In the future you should post vb.net solutions in the vb.net 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?
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?
Why are you turning this into a debate?  I wanted a VB.net 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?