GridGadget

Just starting out? Need help? Post your questions and find answers here.
User avatar
rndrei
Enthusiast
Enthusiast
Posts: 151
Joined: Thu Dec 28, 2023 9:04 pm

GridGadget

Post 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
Last edited by rndrei on Mon Apr 21, 2025 7:09 pm, edited 1 time in total.
infratec
Always Here
Always Here
Posts: 7576
Joined: Sun Sep 07, 2008 12:45 pm
Location: Germany

Re: GridGadget

Post 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
RNBW
User
User
Posts: 71
Joined: Thu Jan 02, 2014 5:01 pm

Re: GridGadget

Post 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
Fred
Administrator
Administrator
Posts: 18153
Joined: Fri May 17, 2002 4:39 pm
Location: France
Contact:

Re: GridGadget

Post by Fred »

Here is a very good grid gadget by said: https://www.purebasic.fr/english/viewto ... 28#p408428
User avatar
mk-soft
Always Here
Always Here
Posts: 6202
Joined: Fri May 12, 2006 6:51 pm
Location: Germany

Re: GridGadget

Post 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 ;)
My Projects ThreadToGUI / OOP-BaseClass / EventDesigner V3
PB v3.30 / v5.75 - OS Mac Mini OSX 10.xx - VM Window Pro / Linux Ubuntu
Downloads on my Webspace / OneDrive
User avatar
rndrei
Enthusiast
Enthusiast
Posts: 151
Joined: Thu Dec 28, 2023 9:04 pm

Re: GridGadget

Post by rndrei »

Thank you, working code!
User avatar
rndrei
Enthusiast
Enthusiast
Posts: 151
Joined: Thu Dec 28, 2023 9:04 pm

Re: GridGadget

Post 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?
User avatar
mk-soft
Always Here
Always Here
Posts: 6202
Joined: Fri May 12, 2006 6:51 pm
Location: Germany

Re: GridGadget

Post by mk-soft »

With Grid Gadget there is no X or Y.
There is talk of Rows and Columns ...
My Projects ThreadToGUI / OOP-BaseClass / EventDesigner V3
PB v3.30 / v5.75 - OS Mac Mini OSX 10.xx - VM Window Pro / Linux Ubuntu
Downloads on my Webspace / OneDrive
User avatar
rndrei
Enthusiast
Enthusiast
Posts: 151
Joined: Thu Dec 28, 2023 9:04 pm

Re: GridGadget

Post 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?
Post Reply