Table column header click 2 tables

Discussion in 'Questions (Windows Mobile)' started by RB Smissaert, Mar 29, 2009.

  1. RB Smissaert

    RB Smissaert Well-Known Member Licensed User

    I can do a table sort with a table column header click with the Door library fine when there is one table only, but sofar no success when there are 2 tables.
    How do I do this? Do I need to add door objects and events for both tables?
    I have done that, but the click event is not picked up for the second table.
    Thanks for any advice.

    RBS
     
  2. Erel

    Erel Administrator Staff Member Licensed User

    Can you upload your code?
     
  3. RB Smissaert

    RB Smissaert Well-Known Member Licensed User

    This is after going back to code where at least it will work with one table.
    There are references to 2 Door objects and 1 Door event.

    What I had done before is duplicated all of the above by having refs to 4 Door objects and 2 Door Events and picked the one according to the table.
    I am not familiar with .net at all, so I am coding a bit in the dark here.


    RBS
     
  4. RB Smissaert

    RB Smissaert Well-Known Member Licensed User

    And here is the whole .sbp file.

    RBS
     
  5. Erel

    Erel Administrator Staff Member Licensed User

    You need one Event object for each table.
    See this code for an example (file is attached):
    Code:
    Sub Globals
        
    'Declare the global variables here.

    End Sub

    Sub App_Start
        Form1.Show
        table1.AddCol(cNumber,
    "c1",50)
        table1.AddCol(cNumber,
    "c2",50)
        table1.AddCol(cNumber,
    "c3",50)
        
    For i = 1 To 10
            table1.AddRow(
    Rnd(0,11), Rnd(0,11), Rnd(0,11))
        
    Next
        obj.New1(
    True)
        obj.FromControl(
    "table1")
        event1.New1(obj.Value, 
    "MouseDown")
        
        table2.AddCol(cNumber,
    "c1",50)
        table2.AddCol(cNumber,
    "c2",50)
        table2.AddCol(cNumber,
    "c3",50)
        
    For i = 1 To 10
            table2.AddRow(
    Rnd(0,11), Rnd(0,11), Rnd(0,11))
        
    Next
        obj.FromControl(
    "table2")
        event2.New1(obj.Value, 
    "MouseDown")
        AddEvent(
    "event1", NewEvent, "TableClick_Event")
        AddEvent(
    "event2", NewEvent, "TableClick_Event")
    End Sub

    Sub TableClick_Event
        
    Dim strCtrlType
        
    If Sender = "event1" Then table = "Table1" Else table = "Table2"
        obj.Value = 
    Control(Sender,Event).Data
        strCtrlType = GetControlType(
    "table1", _
                                    obj.GetProperty(
    "X"), _
                                    obj.GetProperty(
    "Y"))                        
        form1.Text = table & 
    " " & strCtrlType
    End Sub

    Sub GetControlType(strControlName, x, y)
        obj.FromControl(strControlName)
        obj.Value = obj.RunMethod3(
    "HitTest", x, "System.Int32", y, "System.Int32")
        
    Return obj.GetProperty("Type")
    End Sub
     

    Attached Files:

  6. RB Smissaert

    RB Smissaert Well-Known Member Licensed User

    Thanks for that.
    Looks nice and clear and will try it out tonight and report back.

    RBS
     
  7. RB Smissaert

    RB Smissaert Well-Known Member Licensed User

    All working nicely now and thanks again for clarifying.
    One minor thing I noticed is that if you do a table sort on a hidden column then on the desktop the header sorting image will appear on the visible column nearest to that hidden column and that can be confusing. The device doesn't show this image.

    RBS
     
Loading...
  1. This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
    By continuing to use this site, you are consenting to our use of cookies.
    Dismiss Notice