Page 1 of 1

GridGadget

Posted: Mon Apr 21, 2025 6:23 pm
by rndrei
How to display a table?
I looked on the forum, there is not a single working code!?
As I understand it, you need through ListiconGadget?
Interested in how to remove lines backlighting, so that only on the cells there is a selection?

Code: Select all

 If OpenWindow(0, 0, 0, 400, 150, "ListIcon - Add Columns", #PB_Window_SystemMenu | #PB_Window_ScreenCentered)
    ListIconGadget(0, 10, 10, 380, 100, "Standard Column", 150, #PB_ListIcon_GridLines)
    ButtonGadget(1, 10, 120, 150, 20, "Add new column")
    index = 1     ; "Standard column" has already index 0
    Repeat
      Event = WaitWindowEvent()
      If Event = #PB_Event_Gadget
        If EventGadget() = 1
          AddGadgetColumn(0, index, "Column "+Str(index), 80)
          AddGadgetItem(0,index,"Row"+Str(index))
          index + 1
        EndIf
      EndIf
    Until Event = #PB_Event_CloseWindow
  EndIf

Re: GridGadget

Posted: Mon Apr 21, 2025 7:00 pm
by infratec
Btw. you have a bug in your AddGadgetItem() the index is wrong.

Code: Select all

If OpenWindow(0, 0, 0, 400, 150, "ListIcon - Add Columns", #PB_Window_SystemMenu | #PB_Window_ScreenCentered)
  ListIconGadget(0, 10, 10, 380, 100, "Standard Column", 150, #PB_ListIcon_GridLines)
  ButtonGadget(1, 10, 120, 150, 20, "Add new column")
  index = 1     ; "Standard column" has already index 0
  Repeat
    Event = WaitWindowEvent()
    If Event = #PB_Event_Gadget
      If EventGadget() = 1
        AddGadgetColumn(0, index, "Column " + Str(index), 80)
        AddGadgetItem(0, index - 1, "Row" + Str(index))
        
        SetGadgetItemText(0, index - 1, Str(index), index)
        
        index + 1
      EndIf
    EndIf
  Until Event = #PB_Event_CloseWindow
EndIf
Btw. this is written in the help of the ListIconGadget

Re: GridGadget

Posted: Tue Apr 22, 2025 3:14 pm
by RNBW
A very interesting way to develop a Grid.

What would be really useful would be if there was also a way of adding rows independent of an increased number of columns. There does not appear to be a AddGadgetRow() to complement AddGadgetColumn().

I've answered my own question. REM out the AddGadgetColumn() and it simply adds rows!

Code: Select all

If OpenWindow(0, 0, 0, 400, 150, "ListIcon - Add Columns", #PB_Window_SystemMenu | #PB_Window_ScreenCentered)
  ListIconGadget(0, 10, 10, 380, 100, "Standard Column", 150, #PB_ListIcon_GridLines)
  ButtonGadget(1, 10, 120, 150, 20, "Add new Row")
  index = 1     ; "Standard column" has already index 0
  Repeat
    Event = WaitWindowEvent()
    If Event = #PB_Event_Gadget
      If EventGadget() = 1
        ;AddGadgetColumn(0, index, "Column " + Str(index), 80)
        AddGadgetItem(0, index - 1, "Row" + Str(index))
        
        SetGadgetItemText(0, index - 1, Str(index), index)
        
        index + 1
      EndIf
    EndIf
  Until Event = #PB_Event_CloseWindow
EndIf

Re: GridGadget

Posted: Tue Apr 22, 2025 6:54 pm
by Fred
Here is a very good grid gadget by said: https://www.purebasic.fr/english/viewto ... 28#p408428

Re: GridGadget

Posted: Tue Apr 22, 2025 7:54 pm
by mk-soft
Fred wrote: Tue Apr 22, 2025 6:54 pm Here is a very good grid gadget by said: https://www.purebasic.fr/english/viewto ... 28#p408428
And for said's grid gadget a few updates: https://www.purebasic.fr/english/viewto ... 94#p601094 ;)

Re: GridGadget

Posted: Wed Apr 23, 2025 12:07 pm
by rndrei
Thank you, working code!

Re: GridGadget

Posted: Wed Apr 23, 2025 7:10 pm
by rndrei
mk-soft wrote: Tue Apr 22, 2025 7:54 pm
Fred wrote: Tue Apr 22, 2025 6:54 pm Here is a very good grid gadget by said: https://www.purebasic.fr/english/viewto ... 28#p408428
And for said's grid gadget a few updates: https://www.purebasic.fr/english/viewto ... 94#p601094 ;)
I can’t understand how to get the coordinates of X, Y tables in the window?Is there such a procedure?

Re: GridGadget

Posted: Wed Apr 23, 2025 7:35 pm
by mk-soft
With Grid Gadget there is no X or Y.
There is talk of Rows and Columns ...

Re: GridGadget

Posted: Thu Apr 24, 2025 3:30 am
by rndrei
I can't figure it out!How to hide the title on X?
On y found

Code: Select all

 ShowRowNumbers () 
And what kind of square is hanging in the upper left corner?