John Gates, CISSP, CDPSE
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.
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.
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-
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-
ASKER
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.ToS tring
For i = 0 To h - 1
'MsgBox("iterate the row")
j = TableModel1.Rows(i).AnyCel lsSelected .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-
Dim h As Object
Dim i As Integer
Dim j As String
Dim k As String
h = TableModel1.Rows.Count.ToS
For i = 0 To h - 1
'MsgBox("iterate the row")
j = TableModel1.Rows(i).AnyCel
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.Sele ctionChang ed +=new XPTable.Events.SelectionEv entHandler (TableMode l_Selectio nChanged);
private void TableModel_SelectionChange d(object sender, XPTable.Events.SelectionEv entArgs e)
{
}
In VB it will be like
Addhandler TableModel1.SelectionChang ed, Addressof TableModel_SelectionChange d
and then your handler:
Private sub TableModel_SelectionChange d (sender as object, e as XPTable.Events.SelectionEv entsArgs)
'your selection is inside 'e'
'e.newSelectedIndicies contains your selection
end sub
I did it in C#
but you just need to add a handler to
this.table.TableModel.Sele
private void TableModel_SelectionChange
{
}
In VB it will be like
Addhandler TableModel1.SelectionChang
and then your handler:
Private sub TableModel_SelectionChange
'your selection is inside 'e'
'e.newSelectedIndicies contains your selection
end sub
ASKER
Can you elaborate in VB.NET? with the handler code.. Is my code above close to what needs to be there?
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
Where would this line go?
Addhandler TableModel1.SelectionChang ed, Addressof TableModel1_SelectionChang ed
I get a syntax error anywhere I try to put that on the code page..
This line
Table.Selections.SelectedI tems
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.
Addhandler TableModel1.SelectionChang
I get a syntax error anywhere I try to put that on the code page..
This line
Table.Selections.SelectedI
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.
ASKER
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?
I typed tableModel didnt I?
ASKER
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?
So not very strange to assume you could read c# as well?
ASKER
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?
The TableModel also provides a Selection object that you can use to programmatically select or deselect Cells.
Is that any help?