
EsGRID grid gadget 2.1. Don't post here!
Column resize
I just purchased Es_Grid and run into my first problem:
I have a egrid placed inside a splitter. When i resize my window, i resize the splitter and the embedded egrid seems to resize as well.
All i want to do is to resize the width of the egrid-columns so that they fill my egrid complete.
I did now find anything about resizing columns in the help-file.
Any ideas?
Edit:
Found this hint inside the egrid-help:
I use this now inside a loop across all colums:
Works. Is there another egrid build-in function to resize the columns?
I have a egrid placed inside a splitter. When i resize my window, i resize the splitter and the embedded egrid seems to resize as well.
All i want to do is to resize the width of the egrid-columns so that they fill my egrid complete.
I did now find anything about resizing columns in the help-file.
Any ideas?
Edit:
Found this hint inside the egrid-help:
Code: Select all
SendMessage_(GadgetID(#egrid), #LVM_SETCOLUMNWIDTH, lastcolindex+1, #LVSCW_AUTOSIZE_USEHEADER)
Code: Select all
for i = 1 to numCols
SendMessage_(GadgetID(#egrid), #LVM_SETCOLUMNWIDTH, i, #LVSCW_AUTOSIZE_USEHEADER)
next
An EsGRID is a sub-classed Purebasic ListIcon gadget and so you can use SetGadgetItemAttribute() to alter a column width etc. This is why I did not add such a command to the EsGRID library.
Just remember to add 1 to the coumn index before using SetGadgetItemAttribute() etc.
Just remember to add 1 to the coumn index before using SetGadgetItemAttribute() etc.
I may look like a mule, but I'm not a complete ass.
That is explained somewhere in the manual!univeda wrote:Thank you, Stephen, SetGatdgetItemAttribute works fine with your egrid. But why should i add 1 to the column index?

An EsGRID is a heavily modifed ListIcon gadget with column zero blanked out (for various reasons). Consequently, what EsGRID regards as column 0, for example, Purebasic and Windows regard as column 1 and so on.
I may look like a mule, but I'm not a complete ass.
I think the various demos would show you the way!
Demo 7 in particular colors alternate rows and arranges for the selected row to be colored differently etc.
A simple CellCallback function is all you need.
If you wish a simple example then just let me know and I'll hack one up for you in 20 seconds!

A simple CellCallback function is all you need.
If you wish a simple example then just let me know and I'll hack one up for you in 20 seconds!

I may look like a mule, but I'm not a complete ass.
Thank you again.
I managed it by using this:
Works fine. Your esgrid is really very flexible. Keep up the good work!
I managed it by using this:
Code: Select all
Procedure.i egridCellCallBack(egrid, uMsg, *cellinfo.egridCellInfo)
Protected result
Select uMsg
Case #egrid_HeaderItemClick
;Debug "From CellCallback function: column " + Str(*cellinfo\column) + " clicked."
Case #egrid_FormatCell
If *cellinfo\row = -1 ;Custom header.
*cellinfo\textjustification = #egrid_centerText
Else
If *cellinfo\row % 2 ;Alternating rowColor
*cellinfo\backcolour = RGB($E3, $F1, $FF)
*cellinfo\forecolour = #Black
Else
*cellinfo\backcolour = #White
EndIf
EndIf
Default
result = #True
EndSelect
ProcedureReturn result
EndProcedure
Hi Stephen,
getting more and more into it but... can you please enlight me once again?
I've worked with your examples 3 and 7 but couldn't realize what i call a FullRowSelect.
Can you please provide (and explain) a sample how to use the CellCallBack so that a row is completly selected after a cell in this row is selected?
Thanks again.
Michael
getting more and more into it but... can you please enlight me once again?
I've worked with your examples 3 and 7 but couldn't realize what i call a FullRowSelect.
Can you please provide (and explain) a sample how to use the CellCallBack so that a row is completly selected after a cell in this row is selected?
Thanks again.
Michael
Well, I am not sure there is much I can say beyond what is in demo 3.
First thing to say is that you do not select rows; only cells. This is the same for any grid. What you presumably mean is that you want to highlight the entire row whenever the user selects a cell etc.
In any example, the #egrid_FormatCell handler is responsible for coloring cells. So, for example, in the following #egrid_FormatCell handler, we arrange for every cell within the selected row to have a background color of blue.
Now this is fine, except it will not work properly as yet. If you were to add this to an example, you will find that only the selected cell was getting a background of blue and then some cells would remain with a blue background after you move the focus!
This is because the #egrid_FormatCell message is sent for individual cells only. We need a way of getting this message to fire for all cells within the selected row whenever the user selects a new cell etc.
For this, simply add the following command at the end of your #egrid_SelectCell handler to force a repaint :
You will need a similar line at the end of your #egrid_LosingFocus handler.
Here's a very simple example taking the above points into account :
You may want to remove the focus rectangle from the selected cell by switching : for
First thing to say is that you do not select rows; only cells. This is the same for any grid. What you presumably mean is that you want to highlight the entire row whenever the user selects a cell etc.
In any example, the #egrid_FormatCell handler is responsible for coloring cells. So, for example, in the following #egrid_FormatCell handler, we arrange for every cell within the selected row to have a background color of blue.
Code: Select all
Case #egrid_FormatCell
If *cellinfo\row<>-1 And *cellinfo\row=egrid_SelectedRow(1)
*cellinfo\backcolour = #Blue
EndIf
This is because the #egrid_FormatCell message is sent for individual cells only. We need a way of getting this message to fire for all cells within the selected row whenever the user selects a new cell etc.
For this, simply add the following command at the end of your #egrid_SelectCell handler to force a repaint :
Code: Select all
InvalidateRect_(GadgetID(egrid),0,0)
Here's a very simple example taking the above points into account :
Code: Select all
IncludePath "..\Source\"
XIncludeFile "EsGRID.pbi"
IncludePath ""
Procedure.l MyCellCallBack(egrid, uMsg, *cellinfo.egridCellInfo)
Protected result
Select uMsg
Case #egrid_SelectCell
result=#True
InvalidateRect_(GadgetID(egrid),0,0)
Case #egrid_LosingFocus
result=#True
InvalidateRect_(GadgetID(egrid),0,0)
Case #egrid_FormatCell
If *cellinfo\row<>-1 And *cellinfo\row=egrid_SelectedRow(egrid)
*cellinfo\backcolour = $A5F4F9
EndIf
Default
result = #True ;This accounts for all messages we have decided not to process.
EndSelect
ProcedureReturn result
EndProcedure
If OpenWindow(0,0,0,640,300,"EsGRID demo.",#PB_Window_SystemMenu|#PB_Window_MinimizeGadget|#PB_Window_MaximizeGadget|#PB_Window_Maximize|#PB_Window_ScreenCentered)
egrid_CreateGrid(1, WindowWidth(0)/4, WindowHeight(0)/8, WindowWidth(0)/2, WindowHeight(0)/2,26,#egrid_GridLines|#egrid_AlwaysShowSelection, #egrid_ResizeColumnsTrue|#egrid_MultiLineText)
egrid_CreateCellCallback(1, @MyCellCallBack())
egrid_SetHeaderHeight(1, 42)
egrid_setOption(1, #egrid_SelectionBorderColour, #Black)
egrid_setOption(1, #egrid_SelectionBorderWidth, 2)
For b=0 To 4 ;5 columns.
egrid_AddColumn(1,b,"Col " + Str(b),60)
Next
egrid_AddRows(1,-1, 100)
Repeat
EventID = WaitWindowEvent()
Until EventID = #PB_Event_CloseWindow
EndIf
Code: Select all
egrid_setOption(1, #egrid_SelectionBorderWidth, 2)
Code: Select all
egrid_setOption(1, #egrid_SelectionBorderWidth, 0)
I may look like a mule, but I'm not a complete ass.
I use a CellCallBack to display the CellText as a CellTooltip:
But with some special characters (like this one -> &) there are problems, the &-sign is shown as this: _
Do i have to set a chracter-set or somethins like that?
Michael
Code: Select all
Case #egrid_GetCellTooltip
*cellinfo\text = eGrid_GetCellText(egrid, *cellinfo\column, *cellinfo\row)
result = #True
Do i have to set a chracter-set or somethins like that?
Michael
PB 4.41 Windows x86
Projects: ExTSC - Extended Terminal Services Client | Univeda - Universal Knowledgebase - Dungeon - paused 2D RPG
Projects: ExTSC - Extended Terminal Services Client | Univeda - Universal Knowledgebase - Dungeon - paused 2D RPG
I have altered the EsGRID source not to do that anymore.
Rather than me uploading a new version just for this change; let me direct you to make the alteration yourself.
Load up the main "EsGRID.pbi" source and find the line :
(Just search for Tooltips_Class32).
Change the line to :
**EDIT : univeda, could I please ask that you join the forums over at the nxSoftware site where there is a whole section given over to EsGRID.
Rather than me uploading a new version just for this change; let me direct you to make the alteration yourself.
Load up the main "EsGRID.pbi" source and find the line :
Code: Select all
*pointer\ttip = CreateWindowEx_(0, "Tooltips_Class32", "", #TTS_ALWAYSTIP, 0, 0, 0, 0, 0, 0, 0, 0)
Change the line to :
Code: Select all
*pointer\ttip = CreateWindowEx_(0, "Tooltips_Class32", "", #TTS_ALWAYSTIP|#TTS_NOPREFIX, 0, 0, 0, 0, 0, 0, 0, 0)
**EDIT : univeda, could I please ask that you join the forums over at the nxSoftware site where there is a whole section given over to EsGRID.
I may look like a mule, but I'm not a complete ass.