none
About DataView control RRS feed

  • Question

  • Hi to all.

    What is the main use of the DataView control ?

    Can you give me an example with the presence of two columns with header and filling them ?

    Thanks

    BS

    Thursday, November 8, 2018 4:29 PM

Answers

  • Here's a sample for DataView (5 rows and 5 cols, but should be easy to adjust for different usage)

    ID: TGS200

    Thursday, November 8, 2018 7:59 PM
    Answerer
  • Do you want something like this ... ??

    Intest[1] = "deg"
    Intest[2] = "tan(deg)"
    dv = LDControls.AddDataView(300,300, Intest)
    
    For r = 0 To 180    ' tan repeats after 180°  eg. [-pi/2, +pi/2]
      row = "1="+ r +";2="+ LDMath.Tan(r) +";"  ' LDMath.Tan  uses °, Math.Tan uses rad
      LDControls.DataViewSetRow(dv, r+1,row)  ' row# in DataView starts from 1,2,3, ...
    EndFor
    
    row = ""      ' remove last array elements  (NO LDArray  here)
    Intest = ""


    Monday, November 19, 2018 10:57 PM
    Answerer
  • - How do you color a single column or a single cell ?
    - How do you change the font styles of cells and headers ?

      For a more advanced styling of LD-DataView (DataGridView Class) you should use WinForms from C# or VBnet.

    From SB accessable properties are all under LDControls.DataView...   (in the right IntelliSense pane)

    However, there are some more props using LDShapes.GetProperties, LDShapes.Get/SetProperty.

    Eg. you can set (via LDShapes.SetProperty) properties like..

    FontFamily = Segoe UI            ' default values ...
    FontSize = 12                          ' -""-
    FontStyle = Normal                  ' -""-
    FontWeight = Normal              ' -""-
    Foreground = #FF000000        ' -""-  Text color

    ...

    like:   LDShapes.SetProperty(dv, "FontSize", 10)    ' if your DataView is 'dv'

    To get available properties and default values for an existing DataView 'dv', you can use:

    Sub GetProps
      prop = LDShapes.GetProperties(dv)
      idcs = Array.GetAllIndices(prop)
      For n = 1 To Array.GetItemCount(idcs)
        TextWindow.WriteLine(idcs[n] +" = "+ prop[idcs[n]])
      EndFor
    EndSub



    Saturday, November 24, 2018 7:37 PM
    Answerer
  • Please take a look into   'other-samples\DataView.sb'  in LitDev_v1.2.zip

    which you have downloaded for LitDev extension.

    If something's further unclear then, come back...

    PS: Here' another shorter sample

    dv = LDControls.AddDataView(300,300, "1=col1;2=col2;3=col3;")
    LDControls.DataViewSetColumnButton(dv, 1)
    
    For r = 1 To 10
      row[1] = (r-1)*3 +1
      row[2] = (r-1)*3 +2
      row[3] = (r-1)*3 +3
      LDControls.DataViewSetRow(dv, r, row)
    EndFor
    
    LDControls.DataViewButtonClicked = DVBtnClicked
    
    Sub DVBtnClicked
      arr = LDControls.LastDataViewButtonClicked
      TextWindow.WriteLine("clicked Row:    "+ arr[1])
      TextWindow.WriteLine("cliched Column: "+ arr[2]) 
      TextWindow.WriteLine("Value:          "+ arr[3])
      TextWindow.WriteLine("")
    EndSub
    

    Saturday, December 1, 2018 7:30 PM
    Answerer

All replies

  • Here's a sample for DataView (5 rows and 5 cols, but should be easy to adjust for different usage)

    ID: TGS200

    Thursday, November 8, 2018 7:59 PM
    Answerer
  • The code ?
    Thursday, November 8, 2018 8:35 PM
  • The code ?

      ID ??

      Import ID: TGS200-0  which is ready to run.

    Thursday, November 8, 2018 9:10 PM
    Answerer
  • Thanks for the reply.

    An array can not have a name ?

    For example:

    LDText.Split ("R, G, B, A, W", ",")

    Thank you.

    BS

    Sunday, November 11, 2018 9:30 PM
  • The output array from 'LDText.Split("R,G,B,A,W", ",")'  is just a string which is piped/directed to the input for LDControls.AddDataView, but of course you can define it as an explicit variable, like

    heads = LDText.Split("R,G,B,A,W", ",")

    ' TextWindow.WriteLine("heads: "+ heads)

    and then use it for

    dv = LDControls.AddDataView(w0,135, heads)

    But it's only used once in this sample, so there's no need to introduce a separate variable name here.


    Sunday, November 11, 2018 10:27 PM
    Answerer
  • Hi.
    Thanks for the answers.

    In the line:

    DControls.DataViewAllowUserEntry(dv, "")    ' NO bottom row

    What is the meaning of  ""?
    Should be True or False.

    BS


    Monday, November 12, 2018 9:40 PM
  • "False"

    But simply replace the ""  by "False"  ,  then replace it by "True"  and each time look at the result.

    All that's NOT explicitly "True" (case insensitiv) , is "False" (like "", 0, "foo", "fAlSe", ...)

    Monday, November 12, 2018 10:31 PM
    Answerer
  • GraphicsWindow.Show()
    
    Intest[1] = "x"
    Intest[2] = "f(x)"
    TB = LDControls.AddDataView(300,300,Intest)
    
    For r = 1 TO 1000
      
      s= Math.Tan(r)
      
      ValueSplit = Text.Append(r+",",s)
      
      ValueRow = LDText.Split(ValueSplit,",")
      
      LDControls.DataViewSetRow(TB,r,ValueRow)
      
      LDArray.Delete(ValueRow)
      
    EndFor

    Hi to all.

    Why doesn't it work?

    Thanks

    BS

    Monday, November 19, 2018 9:15 PM
  • Do you want something like this ... ??

    Intest[1] = "deg"
    Intest[2] = "tan(deg)"
    dv = LDControls.AddDataView(300,300, Intest)
    
    For r = 0 To 180    ' tan repeats after 180°  eg. [-pi/2, +pi/2]
      row = "1="+ r +";2="+ LDMath.Tan(r) +";"  ' LDMath.Tan  uses °, Math.Tan uses rad
      LDControls.DataViewSetRow(dv, r+1,row)  ' row# in DataView starts from 1,2,3, ...
    EndFor
    
    row = ""      ' remove last array elements  (NO LDArray  here)
    Intest = ""


    Monday, November 19, 2018 10:57 PM
    Answerer
  • As far as I can see the program works exactly as written.  Perhaps say what you were hoping it would do that it didn't?
    Tuesday, November 20, 2018 6:51 PM
    Moderator
  • One way the original program can go wrong, is if the operating system uses the comma as decimal sign. Then the append and split with a comma goes wrong. When the comma in those two line is changed to a semicolon (;) the split works as it should.

    The error wich remains is the use of radians. These can be be converted to degrees by Math.Getradians in a new line after the For :

    GraphicsWindow.Show()
    
    Intest[1] = "x"
    Intest[2] = "f(x)"
    TB = LDControls.AddDataView(300,300,Intest)
    
    For r = 1 TO 1000
      rr=Math.GetRadians(r)
      s= Math.Tan(rr)
      ValueSplit = Text.Append(r+";",s)
      ValueRow = LDText.Split(ValueSplit,";")
      LDControls.DataViewSetRow(TB,r,ValueRow)
      LDArray.Delete(ValueRow)
    EndFor


    Jan [ WhTurner ] The Netherlands


    • Edited by WhTurner33Editor Wednesday, November 21, 2018 3:44 PM comma to semicolon
    Wednesday, November 21, 2018 2:56 PM
    Answerer
  • Thanks to everyone for the advice.
    Now I wanted to ask you:

    - How do you color a single column or a single cell ?
    - How do you change the font styles of cells and headers ?

    Thank you.

    BS
    Saturday, November 24, 2018 3:19 PM
  • - How do you color a single column or a single cell ?
    - How do you change the font styles of cells and headers ?

      For a more advanced styling of LD-DataView (DataGridView Class) you should use WinForms from C# or VBnet.

    From SB accessable properties are all under LDControls.DataView...   (in the right IntelliSense pane)

    However, there are some more props using LDShapes.GetProperties, LDShapes.Get/SetProperty.

    Eg. you can set (via LDShapes.SetProperty) properties like..

    FontFamily = Segoe UI            ' default values ...
    FontSize = 12                          ' -""-
    FontStyle = Normal                  ' -""-
    FontWeight = Normal              ' -""-
    Foreground = #FF000000        ' -""-  Text color

    ...

    like:   LDShapes.SetProperty(dv, "FontSize", 10)    ' if your DataView is 'dv'

    To get available properties and default values for an existing DataView 'dv', you can use:

    Sub GetProps
      prop = LDShapes.GetProperties(dv)
      idcs = Array.GetAllIndices(prop)
      For n = 1 To Array.GetItemCount(idcs)
        TextWindow.WriteLine(idcs[n] +" = "+ prop[idcs[n]])
      EndFor
    EndSub



    Saturday, November 24, 2018 7:37 PM
    Answerer
  • Hi.
    The dataviewbuttonclicked event what is it for and how do I use it (give me a small example)?

    Thank you.
    Greetings.

    BS


    Saturday, December 1, 2018 6:51 PM
  • Please take a look into   'other-samples\DataView.sb'  in LitDev_v1.2.zip

    which you have downloaded for LitDev extension.

    If something's further unclear then, come back...

    PS: Here' another shorter sample

    dv = LDControls.AddDataView(300,300, "1=col1;2=col2;3=col3;")
    LDControls.DataViewSetColumnButton(dv, 1)
    
    For r = 1 To 10
      row[1] = (r-1)*3 +1
      row[2] = (r-1)*3 +2
      row[3] = (r-1)*3 +3
      LDControls.DataViewSetRow(dv, r, row)
    EndFor
    
    LDControls.DataViewButtonClicked = DVBtnClicked
    
    Sub DVBtnClicked
      arr = LDControls.LastDataViewButtonClicked
      TextWindow.WriteLine("clicked Row:    "+ arr[1])
      TextWindow.WriteLine("cliched Column: "+ arr[2]) 
      TextWindow.WriteLine("Value:          "+ arr[3])
      TextWindow.WriteLine("")
    EndSub
    

    Saturday, December 1, 2018 7:30 PM
    Answerer
  • There is a sample that comes with LitDev download called DataView.sb.

    It uses DataViewButtonClicked.

    This event is for a dataview that has a column of buttons in it, created with DataViewSetColumnButton to set a column as as buttons.

    Saturday, December 1, 2018 7:32 PM
    Moderator
  • Thanks to all.
    Saturday, December 1, 2018 10:30 PM