about ... table

Discussion in 'Questions (Windows Mobile)' started by giannimaione, May 21, 2007.

  1. giannimaione

    giannimaione Well-Known Member Licensed User

    Hi,
    this is my simple code:

    Sub Globals

    End Sub

    Sub App_Start
    Form1.Show
    CreateTable
    End Sub

    Sub CreateTable
    table1.AddCol(cString,"Name",50)
    table1.AddCol(cString,"Phone",50)


    table1.AddRow("Peter","12345678")
    table1.AddRow("Albert","85856587")
    '
    '
    '
    '
    table1.AddRow("Julian","36587811")
    End Sub

    Sub Table1_SelectionChanged (ColName, Row)
    ' this is only event for table ???
    '
    ' can i catch click on Head (name or phone)
    ' i want use sort by name or by phone
    End Sub

    :confused:
     
  2. Erel

    Erel Administrator Staff Member Licensed User

    The underlying control (Datagrid) doesn't support the header click event.
    A new control - ListView will be soon available which will allow this.
    However, it will not allow many other features of the Table control.
     
  3. RandomCoder

    RandomCoder Well-Known Member Licensed User

    If all you are wanting to do is sort by either the name or the number then I don't think this will work as the value is not actually being changed and so the event won't be fired.
    As an alternative why not try using the MouseDown event on the Form, you could say that if x is <120 Then sort by name else sort by number.

    Regards,
    RandomCoder
     
  4. giannimaione

    giannimaione Well-Known Member Licensed User

    Hey RandomCoder,

    I do not understand
    Can you make example?
    Regards,
    Gianni
     
  5. RandomCoder

    RandomCoder Well-Known Member Licensed User

    It's better for you to try first and if you experience a problem then were all here to help out.

    Basically what I was meaning by...
    is that if the stylus is tapped in the first half of the screen, i.e. where the name column is then sort the table by name else if tapped in the other half of the screen then sort by the number (presuming that the table divides the screen in two).

    Of course you could narrow down the positions so that only the table headers are covered, and I'd also advise setting the table enabled to false so that you can't accidentally change any values. When you need to change/add new values you could have a button at the bottom of the screen that allows this to be done.

    If you really feel that you want me to do it for you I will, it's just that I find it's always better to learn by trial and error rather than being handed a solution.
    Just remember that there's are no rights and wrongs with programming its like handwriting - everyone has there own style! (of course some peoples handwriting is more elegant than others ;))

    Regards,
    RandomCoder
     
  6. giannimaione

    giannimaione Well-Known Member Licensed User

    Yes,
    it is a nice and easy solution.
     
Loading...