[Module] GridExModule.pbi

Share your advanced PureBasic knowledge/code with the community.
User avatar
Thorsten1867
Addict
Addict
Posts: 1366
Joined: Wed Aug 24, 2005 4:02 pm
Location: Germany

Re: [Module] GridExModule.pbi

Post by Thorsten1867 »

Try this one.
Translated with http://www.DeepL.com/Translator

Download of PureBasic - Modules
Download of PureBasic - Programs

[Windows 11 x64] [PB V5.7x]
wombats
Enthusiast
Enthusiast
Posts: 663
Joined: Thu Dec 29, 2011 5:03 pm

Re: [Module] GridExModule.pbi

Post by wombats »

That seems to have fixed that. Thanks.

I'm not sure AddRow() is returning the right value. I assume it is supposed to return the number of the new row. Is that right? Can you check it, please? I'm afraid I don't really understand the code.
User avatar
Thorsten1867
Addict
Addict
Posts: 1366
Joined: Wed Aug 24, 2005 4:02 pm
Location: Germany

Re: [Module] GridExModule.pbi

Post by Thorsten1867 »

AddRow() returns the new number of rows.
Translated with http://www.DeepL.com/Translator

Download of PureBasic - Modules
Download of PureBasic - Programs

[Windows 11 x64] [PB V5.7x]
wombats
Enthusiast
Enthusiast
Posts: 663
Joined: Thu Dec 29, 2011 5:03 pm

Re: [Module] GridExModule.pbi

Post by wombats »

Thorsten1867 wrote:AddRow() returns the new number of rows.
Ah, OK. Thanks for clarifying that.
QuimV
Enthusiast
Enthusiast
Posts: 337
Joined: Mon May 29, 2006 11:29 am
Location: BARCELONA - SPAIN

Re: [Module] GridExModule.pbi

Post by QuimV »

Please,
How much rows and cols can I add to the GridEx.
In my test I can add only 12 rows!!
Is that correct?
Thanks
QuimV
User avatar
Thorsten1867
Addict
Addict
Posts: 1366
Joined: Wed Aug 24, 2005 4:02 pm
Location: Germany

Re: [Module] GridExModule.pbi

Post by Thorsten1867 »

Actually, the number of rows should not matter. Can you describe the problem in more detail?
Translated with http://www.DeepL.com/Translator

Download of PureBasic - Modules
Download of PureBasic - Programs

[Windows 11 x64] [PB V5.7x]
QuimV
Enthusiast
Enthusiast
Posts: 337
Joined: Mon May 29, 2006 11:29 am
Location: BARCELONA - SPAIN

Re: [Module] GridExModule.pbi

Post by QuimV »

This is my code:

Code: Select all

XIncludeFile("GridExModule.pbi")

Enumeration
  #Win
  #Container
  #Container2
  #Button1
  #Button2
EndEnumeration

Global Grid1

Procedure OnButtonClicked()
  row = GridEx::GetAttribute(Grid1, GridEx::#Attrib_Row)
  GridEx::AddRow(Grid1, "new" + #CRLF$ + "Column 2", row - 1)
  GridEx::Refresh(Grid1)
EndProcedure

If OpenWindow(#Win, 0, 0, 800, 470, "GridEX - Gadget", #PB_Window_SystemMenu|#PB_Window_MinimizeGadget|#PB_Window_MaximizeGadget|#PB_Window_ScreenCentered|#PB_Window_SizeGadget)
  
  ButtonGadget(#Button1, 350, 10, 100, 30, "Add Row")

  Grid1 = GridEx::Gadget(#Win, #PB_Any, 10, 10, 300, 250, 6, 7, GridEx::#NoScrollBars)
  GridEx::SetFont(Grid1, "Arial", 10) : GridEx::Refresh(Grid1)
  
  BindGadgetEvent(#Button1, @OnButtonClicked())
  
  
  Repeat
    event = WaitWindowEvent()
  Until event = #PB_Event_CloseWindow
  
EndIf
Click button #Button1 more than 12 times, please
Max number of rows are 12
QuimV
User avatar
Thorsten1867
Addict
Addict
Posts: 1366
Joined: Wed Aug 24, 2005 4:02 pm
Location: Germany

Re: [Module] GridExModule.pbi

Post by Thorsten1867 »

I tested the code and could add over 30 lines.
Translated with http://www.DeepL.com/Translator

Download of PureBasic - Modules
Download of PureBasic - Programs

[Windows 11 x64] [PB V5.7x]
QuimV
Enthusiast
Enthusiast
Posts: 337
Joined: Mon May 29, 2006 11:29 am
Location: BARCELONA - SPAIN

Re: [Module] GridExModule.pbi

Post by QuimV »

:oops: @Thorsten1867
My mistake is that I expected a vertical scroll bar to appear
Thanks
QuimV
QuimV
Enthusiast
Enthusiast
Posts: 337
Joined: Mon May 29, 2006 11:29 am
Location: BARCELONA - SPAIN

Re: [Module] GridExModule.pbi

Post by QuimV »

When I press the up or down arrows, the selected cell loses focus.
If I press the left or right arrows, the focus is restored.
Is this correct?
I use a virtual machine windows 7 professional 32 bits and PB5.61
QuimV
Dave L
New User
New User
Posts: 6
Joined: Sat Aug 14, 2010 9:27 am

Re: [Module] GridExModule.pbi

Post by Dave L »

I have noticed an unexpected result in the #Cash column.

In example 1 I entered value -2500000,65 and it displayed as -2.500.000,75.

PB function works as expected: FormatNumber(-2500000.65,2,",",".") = -2.500.000,65.

I work on financial software, #Cash columns with correct outcome are helpful :wink:

Is #Cash formatting reliable ?


Update:
Found it: in _FormatCell() replace ValF() with ValD() and everything works fine ...
kinglestat
Enthusiast
Enthusiast
Posts: 732
Joined: Fri Jul 14, 2006 8:53 pm
Location: Malta
Contact:

Re: [Module] GridExModule.pbi

Post by kinglestat »

Really well done
I may not help with your coding
Just ask about mental issues!

http://www.lulu.com/spotlight/kingwolf
http://www.sen3.net
wombats
Enthusiast
Enthusiast
Posts: 663
Joined: Thu Dec 29, 2011 5:03 pm

Re: [Module] GridExModule.pbi

Post by wombats »

When right-clicking on the grid, it cancels the selection. Is there a way to change that? If a popup menu is opened, the user will be expecting the selected item to affect the selection they made. If that selection is cancelled, the popup menu won't do as they expect.

Also, what's the best way to get the currently selected row(s)? I do the following, but when multiple rows are selected, it always returns those rows as the selection, and it doesn't allow for single selection.

Code: Select all

GridEx::GetSelection(*grid)
firstRow = GridEx::Area\Row\First
lastRow = GridEx::Area\Row\Last
Finally, when the grid has only a single column, and it is longer than the width of the gadget, the scrollbar doesn't adjust so the user can see the rest of the cell.
collectordave
Addict
Addict
Posts: 1309
Joined: Fri Aug 28, 2015 6:10 pm
Location: Portugal

Re: [Module] GridExModule.pbi

Post by collectordave »

I am trying to use the GridEx module to display a lengthy dataset in 200 row chunks. Number of rows in Gridex set to 200

I set the Vscroll maximum to the number of rows in the dataset.

After clicking the VScroll it counts up to 182 but no further. I can get the next 200 records by adding up the number of offsets used but the VSCroll value returned by

Debug GetGadgetState(gridex::GetAttribute(DBGrid,Gridex::#Attrib_GadgetRowScroll)) never climbs above the 182. It appears tied to the number of rows in the grid.

I would prefer to use the gadget state to select the next 200 records.

Can I get over this?

Regards

CD
Any intelligent fool can make things bigger and more complex. It takes a touch of genius — and a lot of courage to move in the opposite direction.
collectordave
Addict
Addict
Posts: 1309
Joined: Fri Aug 28, 2015 6:10 pm
Location: Portugal

Re: [Module] GridExModule.pbi

Post by collectordave »

Got over the problem by creating the grid with no scroll bars and adding my own to the side.

Works a treat now.
Any intelligent fool can make things bigger and more complex. It takes a touch of genius — and a lot of courage to move in the opposite direction.
Post Reply