• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 460
  • Last Modified:

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.
0
John Gates, CISSP
Asked:
John Gates, CISSP
  • 7
  • 5
1 Solution
 
PockyMasterCommented:
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?
0
 
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,
-D-
0
 
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

                '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-
0
VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

 
PockyMasterCommented:
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
0
 
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?

0
 
PockyMasterCommented:
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)
next

probably in your case you replace table.TableModel by TabelModel1
0
 
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
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.
0
 
John Gates, CISSPSecurity ProfessionalAuthor Commented:
I finally figured it out...  In the future you should post vb.net solutions in the vb.net thread not C#..
0
 
PockyMasterCommented:
Uhm, I posted VB.NET code as well, didnt i? And where did I type table.selections?
I typed tableModel didnt I?
0
 
John Gates, CISSPSecurity ProfessionalAuthor Commented:
The answer I accepted was in VB correct.
0
 
PockyMasterCommented:
Well, the sample on the website you posted was in c#..
So not very strange to assume you could read c# as well?
0
 
John Gates, CISSPSecurity ProfessionalAuthor Commented:
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?
0

Featured Post

What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

  • 7
  • 5
Tackle projects and never again get stuck behind a technical roadblock.
Join Now