Second click on table cell

Discussion in 'Questions (Windows Mobile)' started by PatrikL, May 15, 2009.

  1. PatrikL

    PatrikL Member Licensed User

    Hi,

    I need help with this problem.

    I need procedure for click on table cell. On first click I need select cell, on second click I want do something. But table dont have event onClick. Exist any workaround? This is my test code, but this code dont work.

    Code:
    Sub Globals
       
    'Declare the global variables here.
       Dim crow
       
    Dim ccol
    End Sub

    Sub App_Start
       Form1.Show
       Table1.AddCol (cNumber, 
    "ID"50True)
       Table1.AddCol (cString, 
    "Name"50)
       Table1.AddRow (
    234564"John")
       Table1.AddRow (
    987654"Kate")
    End Sub



    Sub Table1_SelectionChanged (ColName, Row)
       
    If ((crow = Row) AND (ccol = ColName)) Then
          
    Msgbox("Click on " & Table1.Cell(ColName,Row))
       
    End If   
       crow = Row
       ccol = ColName
    End Sub
     
  2. Erel

    Erel Administrator Staff Member Licensed User

  3. agraham

    agraham Expert Licensed User

    I tried that but it doesn't work. Once the cell is selected the Textbox hosted by the Table gets the focus and the Table (DataGrid) itself gets no more events so you see the first MouseDown event but not the second. :(

    I believe it can be done in C# but it is a bit laborious as it involves installing event handlers on the Textbox in each DataGridTextBoxColumn and that only works on the desktop anyway as the device doesn't have the DataGridTextBoxColumn.TextBox property needed.
     
  4. Cableguy

    Cableguy Expert Licensed User

    How about a simple flag?
    Something like this:

    Code:
    Sub Globals
       
    'Declare the global variables here.
       Dim crow
       
    Dim ccol
    End Sub

    Sub App_Start
       Form1.Show
       Table1.AddCol (cNumber, 
    "ID"50True)
       Table1.AddCol (cString, 
    "Name"50)
       Table1.AddRow (
    234564"John")
       Table1.AddRow (
    987654"Kate")
    End Sub



    Sub Table1_SelectionChanged (ColName, Row)
       
    If ((crow <> Row) AND (ccol <> ColName)) Then
                 
    'First click
          Msgbox("1st Click on " & Table1.Cell(ColName,Row))
                              crow=Row
                              ccol=ColName
                 
    Else If ((crow = Row) AND (ccol = ColName)) Then
                 
    'Second click
                             Msgbox("2nd Click on " & Table1.Cell(ColName,Row))
       
    End If   
    End Sub
    [/QUOTE]
     
  5. agraham

    agraham Expert Licensed User

    Your code is no different to his example. You don't get a second SelectionChanged event when you click on an already selected cell.
     
  6. LineCutter

    LineCutter Active Member Licensed User

    Fake the cell activation (draw a box around the cell in the foreground layer) & redirect the selection to another (invisible) cell. Set a flag & check that on table selection_changed??
     
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