Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

XPTable SelectionChanged

Posted on 2006-11-05
11
Medium Priority
?
988 Views
Last Modified: 2012-06-21
Need som help with SelectionChanged on the XPTable

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

I have this..

Private Sub TableTest_SelectedIndexChanged(ByVal sender As System.Object, ByVal e As XPTable.Events.SelectionEventArgs) Handles TableTest_.SelectionChanged

End sub

I need this for the XPTable

    Private Sub ListView1_SelectedIndexChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ListView1.SelectedIndexChanged
        If (ListView1.SelectedItems.Count) > 0 Then
            Dim this As Integer = DirectCast(ListView1.SelectedItems(0), ListViewItem).Index
            Dim strTemp As String

            Try
                If this >= 0 Then
                    ' Get the marked item from listview
                    strTemp = (ListView1.SelectedItems(0).SubItems(0).Text).ToString
                End If
            Catch ex As Exception
                Throw ex
            End Try

        End If
    End Sub
0
Comment
Question by:NissePPP
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 6
  • 5
11 Comments
 
LVL 1

Author Comment

by:NissePPP
ID: 17877122
I can add this code if this will help, but I don't want to use the loop, I don't have any multi select on rows          

This works.. (For Each...) )bur I want the    strTemp = (ListView1.SelectedItems(0).SubItems(0).Text).ToString

For Each row As XPTable.Models.Row In TableTest.TableModel.Selections.SelectedItems
            '    'show the item in your first column
              MessageBox.Show(row.Cells(0).Text)
Next
 
I have tested this but this only selects the row and cell I i want, but I need the row the user selects            .

strTemp = TableTest.TableModel.Item(intRow, intCell).Text().ToString()

Maybe this code can help..
0
 
LVL 96

Expert Comment

by:Bob Learned
ID: 17881674
Confused.

Bob
0
 
LVL 1

Author Comment

by:NissePPP
ID: 17883136
Ok..

I have a XPTable. it's a modified listview.

I need a function that works like my listveiw function.

This function is used when I need to collect data from a row. When selectedindex is changed.. I can get the row that the user has clicked on..

 Private Sub ListView1_SelectedIndexChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ListView1.SelectedIndexChanged
...........
.........
End sub

Now I need the same for my xptable..

And this is what I have now.. It works when selectedindex is change the te sub is executed,,

Private Sub TableTest_SelectedIndexChanged(ByVal sender As System.Object, ByVal e As XPTable.Events.SelectionEventArgs) Handles TableTest_.SelectionChanged

End sub

But I need the code inside this function . To get the data from the row.



I need this code for the xptable. It's not possible to just change the listview with the xptable.
So I need to translate this, so it works with xptable..


        If (ListView1.SelectedItems.Count) > 0 Then
            Dim this As Integer = DirectCast(ListView1.SelectedItems(0), ListViewItem).Index
            Dim strTemp As String

            Try
                If this >= 0 Then
                    ' Get the marked item from listview
                    strTemp = (ListView1.SelectedItems(0).SubItems(0).Text).ToString
                End If
            Catch ex As Exception
                Throw ex
            End Try

        End If
0
Concerto's Cloud Advisory Services

Want to avoid the missteps to gaining all the benefits of the cloud? Learn more about the different assessment options from our Cloud Advisory team.

 
LVL 96

Expert Comment

by:Bob Learned
ID: 17883166
Where are you having problems with that code?

Bob
0
 
LVL 1

Author Comment

by:NissePPP
ID: 17883306
I need this for the XPtable..    

    If (ListView1.SelectedItems.Count) > 0 Then
            Dim this As Integer = DirectCast(ListView1.SelectedItems(0), ListViewItem).Index
            Dim strTemp As String

            Try
                If this >= 0 Then
                    ' Get the marked item from listview
                    strTemp = (ListView1.SelectedItems(0).SubItems(0).Text).ToString
                End If
            Catch ex As Exception
                Throw ex
            End Try
 Eind if


But i can't just do this.. Xptable object name is TableTest


This dosen't work..

    If (TableTest.SelectedItems.Count) > 0 Then
            Dim this As Integer = DirectCast(TableTest.SelectedItems(0), ListViewItem).Index
            Dim strTemp As String

            Try
                If this >= 0 Then
                    ' Get the marked item from listview
                    strTemp = (TableTest.SelectedItems(0).SubItems(0).Text).ToString
                End If
            Catch ex As Exception
                Throw ex
            End Try
      end if
0
 
LVL 96

Expert Comment

by:Bob Learned
ID: 17897290
If you are using XPTable.Models.Table, it has the SelectionChanged event, and this:

      XPTable.Models.Row row = this.table.SelectedItems[0];

Bob
0
 
LVL 1

Author Comment

by:NissePPP
ID: 17899349
Hmm ok, but I need to get the iitem from the selected row

 strTemp = (TableTest.SelectedItems(0).SubItems(0).Text).ToString ...but  with xxptable code..

how does

XPTable.Models.Row row = Me.table.SelectedItems(0)

get the selected row from my XpTable and into my string variable.

I'm new on this sorry.. :(

 
0
 
LVL 96

Expert Comment

by:Bob Learned
ID: 17899564
XPTable.Models.Row row = this.table.SelectedItems[0];
string strTemp = row.Cells[0].Text;

Bob
0
 
LVL 1

Author Comment

by:NissePPP
ID: 17907062
Thx.. works great. But how do I count the selected rows.

I want to do this.. But I can't find count.

TableTest.SelectedItems.Count
0
 
LVL 96

Accepted Solution

by:
Bob Learned earned 2000 total points
ID: 17907077
SelectedItems is an array, so you need this:

   TableTest.SelectedItems.Length

Bob
0
 
LVL 1

Author Comment

by:NissePPP
ID: 17907523
This is the complete code if any want it..

Thx Bob for all the help.. :)

Private Sub TableTest_SelectedIndexChanged(ByVal sender As System.Object, ByVal e As XPTable.Events.SelectionEventArgs) Handles TableTest.SelectionChanged

        If (TableTest.SelectedItems.Length) > 0 Then
            Dim this As Integer = DirectCast(TableTest.SelectedItems(0), XPTable.Models.Row).Index
            Dim strTemp As String
            Dim row As XPTable.Models.Row

            Try
                If this >= 0 Then
                    ' Get the marked item from listview
                    row = Me.TableTest.SelectedItems(0)
                    strTemp = row.Cells(0).Text
                End If
            Catch ex As Exception
                Throw ex
            End Try
        End If

End sub
0

Featured Post

Concerto Cloud for Software Providers & ISVs

Can Concerto Cloud Services help you focus on evolving your application offerings, while delivering the best cloud experience to your customers? From DevOps to revenue models and customer support, the answer is yes!

Learn how Concerto can help you.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Article by: jpaulino
XML Literals are a great way to handle XML files and the community doesn’t use it as much as it should.  An XML Literal is like a String (http://msdn.microsoft.com/en-us/library/system.string.aspx) Literal, only instead of starting and ending with w…
It was really hard time for me to get the understanding of Delegates in C#. I went through many websites and articles but I found them very clumsy. After going through those sites, I noted down the points in a easy way so here I am sharing that unde…
Sometimes it takes a new vantage point, apart from our everyday security practices, to truly see our Active Directory (AD) vulnerabilities. We get used to implementing the same techniques and checking the same areas for a breach. This pattern can re…
In response to a need for security and privacy, and to continue fostering an environment members can turn to for support, solutions, and education, Experts Exchange has created anonymous question capabilities. This new feature is available to our Pr…

704 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question