Canvas based Grid gadget

Share your advanced PureBasic knowledge/code with the community.
LiK137
Enthusiast
Enthusiast
Posts: 279
Joined: Wed Jun 23, 2010 5:13 pm

Re: Canvas based Grid gadget

Post by LiK137 »

Very nice gadget and useful.
Adding few hundred records to grid with sql select loop is may seem no problem but 6K records take 20 seconds with elapsedmilliseconds and disabled debugger on intel i5 8GB RAM. 27MB RAM and 50% CPU is used.

Would be very thankful for solution.
User avatar
skywalk
Addict
Addict
Posts: 3972
Joined: Wed Dec 23, 2009 10:14 pm
Location: Boston, MA

Re: Canvas based Grid gadget

Post by skywalk »

Rich gadgets are not intended to populate entire data set. Change your code to fill only 50 or whatever records and use scrollbars to update.
The nice thing about standards is there are so many to choose from. ~ Andrew Tanenbaum
LiK137
Enthusiast
Enthusiast
Posts: 279
Joined: Wed Jun 23, 2010 5:13 pm

Re: Canvas based Grid gadget

Post by LiK137 »

Thank You very much.
I got that part but scrolling is not working.

I have digged deeper and found that "shift", "ctrl" and "ctrl"+"shift" handled but not #PB_Canvas_Shift and Srolling

Strange part that MyGrid example is working.
Last edited by LiK137 on Thu Apr 04, 2019 9:42 pm, edited 1 time in total.
said
Enthusiast
Enthusiast
Posts: 342
Joined: Thu Apr 14, 2011 6:07 pm

Re: Canvas based Grid gadget

Post by said »

LiK137 wrote:Very nice gadget and useful.
Adding few hundred records to grid with sql select loop is may seem no problem but 6K records take 20 seconds with elapsedmilliseconds and disabled debugger on intel i5 8GB RAM. 27MB RAM and 50% CPU is used.

Would be very thankful for solution.
Hi,

To load big number of rows, i would use it this way (not sure if you are not using it already though):

Code: Select all

MyGrid::NoRedraw(Gadget)
.... load huge data here ...
MyGrid::Redraw(Gadget)
What skywalk has mentioned is certainly very valid, however the events received by the scrollbars are bound to an internal procedures via BindGadgetEvent() that synchronize the drawing _SynchronizeGridCols() and _SynchronizeGridRows() ... It wont be easy to change those routines so you can intercept scrollbars events! At least i wont do it myself! Not sure if more recent versions of PB offer more flexibility regrading scrollbars events, i am no longer using PB these days



Said
LiK137
Enthusiast
Enthusiast
Posts: 279
Joined: Wed Jun 23, 2010 5:13 pm

Re: Canvas based Grid gadget

Post by LiK137 »

Thank You very much.

I agree with that big data should be handled by partial load with scrolling.

And I see that scrolling is handled and index is changing based on direction of scrolling.
Arrow keys with any combination (Ctrl and/or Shift) events are handled
MoveLeft...MoveDown is Handled but grid is not changing/refreshing.

Finaly, Redraw(Gadget) was just resizing while NoRedraw(Gadget) was changing flag permanently.
That is why grid was not refresing. Just Copied NoRedraw as AutoRedraw with flag set #True.

ThanQ very much again for replies.
User avatar
singo
User
User
Posts: 35
Joined: Mon Apr 23, 2007 4:50 am
Location: Nabiac NSW Australia

Re: Canvas based Grid gadget

Post by singo »

@said

Thank you very much for your Grid gadget, I have used it successfully in one project already in combination with Google SQL Cloud.

I was wondering if it was possible to have something like

EditCell(Gadget.i, Row, Col, SetCellFocus = #True)

where after calling the cell is ready for immediate editing, without having to click the mouse to start the editing process.

P.S. Seasons Greetings ! :)
Singo
Win10, Win7, Debian x86 & OSX ~ PB 5.70 LTS
Minimbah NSW Australia
User avatar
mk-soft
Always Here
Always Here
Posts: 5333
Joined: Fri May 12, 2006 6:51 pm
Location: Germany

Re: Canvas based Grid gadget

Post by mk-soft »

Is like Excel, only not the F2 key but the Enter key.

Had once added the F2 key for editing
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
singo
User
User
Posts: 35
Joined: Mon Apr 23, 2007 4:50 am
Location: Nabiac NSW Australia

Re: Canvas based Grid gadget

Post by singo »

Thank you and yes AFTER clicking an editable cell you can then use the Return key.

But I want my program to do this NOT the user.

I would like my program to start and immediately be in an editable cell without any user clicking the mouse or pressing any keys.

Is this possible ?

Thank you
Singo
Win10, Win7, Debian x86 & OSX ~ PB 5.70 LTS
Minimbah NSW Australia
said
Enthusiast
Enthusiast
Posts: 342
Joined: Thu Apr 14, 2011 6:07 pm

Re: Canvas based Grid gadget

Post by said »

singo wrote:
I would like my program to start and immediately be in an editable cell without any user clicking the mouse or pressing any keys.
Hi Singo,

First, glad to hear that my work was helpful to you, you are welcome ... and Seasons Greetings to everyone
I see the great mk-soft is trying to help as always!

The default editing mode is: when in a cell, you start typing and you exit with any keys ... you overwrite existing content
The other mode is you hit enter in a cell and then the caret is placed at the end of current cell-text, so any new typed text is placed at the end ... you are appending new text to existing one

Back to your question, i believe this is the default mode, am i missing something here?

Said
User avatar
mk-soft
Always Here
Always Here
Posts: 5333
Joined: Fri May 12, 2006 6:51 pm
Location: Germany

Re: Canvas based Grid gadget

Post by mk-soft »

I think he wants to initialize the edit mode from a cell via the program, but this is not a standard.
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
singo
User
User
Posts: 35
Joined: Mon Apr 23, 2007 4:50 am
Location: Nabiac NSW Australia

Re: Canvas based Grid gadget

Post by singo »

mk-soft wrote:I think he wants to initialize the edit mode from a cell via the program, but this is not a standard.
Yes, exactly, I'm sorry if I wasn't clear but that is what I want to do.

I want to use the grid for data entry and I don't want the user to have to click every time they want to make an entry.
Singo
Win10, Win7, Debian x86 & OSX ~ PB 5.70 LTS
Minimbah NSW Australia
User avatar
mk-soft
Always Here
Always Here
Posts: 5333
Joined: Fri May 12, 2006 6:51 pm
Location: Germany

Re: Canvas based Grid gadget

Post by mk-soft »

Version: v2.4
Update: 16.02.2022
- Added SetStyleItemList
- Added Keyboard Escape, Tab, Return to Combo
- Optimize open combo (position up or down)

Link: https://github.com/mk-soft-65/MyGrid/tr ... e-function
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
captain_skank
Enthusiast
Enthusiast
Posts: 636
Joined: Fri Oct 06, 2006 3:57 pm
Location: England

Re: Canvas based Grid gadget

Post by captain_skank »

A very nice grid control.

I'm probably misunderstanding this, but can individual row heights be set ? I've tried both :

SetRowHeight(Gadget.i, GRow.i, Height.i = #Default_RowHeight) and
AutoHeightRow(Gadget.i, GRow)

But it's unclear if this row specific or global.

I need to have variable row heights when getting text and blobs(text again) from a database so i currently use the web gadget and HTML tables but it's not as fast in data population and i have to limit it to about 200 rows.

Cheers
User avatar
mk-soft
Always Here
Always Here
Posts: 5333
Joined: Fri May 12, 2006 6:51 pm
Location: Germany

Re: Canvas based Grid gadget

Post by mk-soft »

The height is only calculated on one line.
Let's see how I can adjust this. Maybe I will use my DrawTextBox function and also support fixed line breaks.

At time only on line ...

Code: Select all

    Define row
    For row = 1 To MyGrid::GetRowCount(#Grid_Nbr)
      MyGrid::AutoHeightRow(#Grid_Nbr, row)
    Next
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
MarcoAb
New User
New User
Posts: 5
Joined: Wed Aug 10, 2022 6:40 am

Re: Canvas based Grid gadget

Post by MarcoAb »

Thanks in advance for this really useful Grid.
There is the possibility to decide how many rows can appear when I use a col type COMBO ?
I can change color, font. height ec.. but I can't find a way to make appear more than 5 lines of choice.
ok i can scroll but for a long list of choices (eg 20) it is faster to click on the chosen item.

Cheers
Post Reply