Menu

How to get contents of a cell in the same row

Help
2007-03-28
2013-04-23
  • Nobody/Anonymous

    i have override the OnClick event and can determine that i clicked cell (2,5).  i want to reference the value in (2,0).  how do i reference the value of a cell in column 0 of any cell that is clicked in a given row?

     
    • Davide Icardi

      Davide Icardi - 2007-03-28

      From a CellContext you can get the grid instance using the Grid property.
      You can cast it to a SourceGrid.Grid object and so read and write to any cells.

      Davide

       
    • Nobody/Anonymous

      ok, i am a little lost.

      i if do this:

                Dim val As Object = sender.Position
                  Dim work() As String = val.ToString.Split(CChar(";"))
                  If Not val Is Nothing Then
                      MessageBox.Show(sender.Grid, val.ToString & " " & work(0))
                  End If

      i can see that i clicked (2,5)

      it is not apparent to me how i can get column 0 of row 2

       
      • Davide Icardi

        Davide Icardi - 2007-03-28

        This is a code for VB (if I remember well the VB syntax):

        DirectCast(sender.Grid, SourceGrid.Grid).Item(0, 2).Value

        Davide

         
    • Nobody/Anonymous

      thanx. it is actually

      valueTest = DirectCast(sender.Grid, SourceGrid.Grid).Item(2, 0).Value

       

Log in to post a comment.

Want the latest updates on software, tech news, and AI?
Get latest updates about software, tech news, and AI from SourceForge directly in your inbox once a month.