Overview
Examples
Screenshots
Comparisons
Applications
Download
Documentation
Tutorials
Bazaar
Status & Roadmap
FAQ
Authors & License
Forums
Funding Ultimate++
Search on this site
Search in forums












SourceForge.net Logo
Home » U++ Library support » ArrayCtrl, HeaderCtrl & GridCtrl » How to hide/show gridctrl column at runtime
How to hide/show gridctrl column at runtime [message #44456] Fri, 13 March 2015 14:04 Go to next message
koldo is currently offline  koldo
Messages: 3355
Registered: August 2008
Senior Veteran
grid has ResizeColMode(0).

grid.GetColumn(2).Hidden(show) works, but GridCtrl field is not visually refreshed properly.


Best regards
Iñaki
Re: How to hide/show gridctrl column at runtime [message #44483 is a reply to message #44456] Mon, 16 March 2015 11:41 Go to previous messageGo to next message
koldo is currently offline  koldo
Messages: 3355
Registered: August 2008
Senior Veteran
Hello Daniel

After hacking a little bit in GridCtrl I have commented out this in Hidden() function:

GridCtrl::ItemRect& GridCtrl::ItemRect::Hidden(bool b)
{
	hidden = b;
//	if(hidden)
//		size = 0;
	return *this;
}

In addition, after calling Hidden() I call Show(false) to the EditFields assigned to Hidden columns

With these changes the results are like this

index.php?t=getfile&id=4755&private=0
It is not perfect but at least it is functional by now.
  • Attachment: Screen.png
    (Size: 5.83KB, Downloaded 765 times)


Best regards
Iñaki
Re: How to hide/show gridctrl column at runtime [message #44497 is a reply to message #44483] Wed, 18 March 2015 08:36 Go to previous messageGo to next message
unodgs is currently offline  unodgs
Messages: 1366
Registered: November 2005
Location: Poland
Ultimate Contributor

GetColumn() methods should be rather used before application window appears - for grid initialization. They don't refresh the grid. But you can call
Repaint(true, false);
to force it. You can also call
ShowColumn(int n, true) or HideColumn(int n, true)
instead. I'm aware this is not so intuitive but it should solve your problem.
Re: How to hide/show gridctrl column at runtime [message #44499 is a reply to message #44497] Wed, 18 March 2015 12:18 Go to previous messageGo to next message
koldo is currently offline  koldo
Messages: 3355
Registered: August 2008
Senior Veteran
Thank you Daniel

I did not know Repaint() function. It does not work with GetColumn() but it does with ShowColumn()/HideColumn(), although when the columns are hidden, a blank area appears as in the image inclosed before.

Important: The grid is defined Editing().ResizeColMode(0).


Best regards
Iñaki
Re: How to hide/show gridctrl column at runtime [message #48745 is a reply to message #44456] Sat, 09 September 2017 21:33 Go to previous message
forlano is currently offline  forlano
Messages: 1182
Registered: March 2006
Location: Italy
Senior Contributor
Hello,

I am resuming this old thread because my problem is exactly the same (U++ 11300, MS2017).
My GridCtrl has 16 columns and the one in position 15 is hided.
Then an OptionButton hide/show it when pressed. Here is the code:
void VegaTab1::ShowInfoCol()
{  
   if (optGrid.Get()) {
   	  grid.GetColumn(15).Hidden(false);
   	  grid.Repaint(true, false);
   }
   else {
   	  grid.GetColumn(15).Hidden(true);
   	  grid.Repaint(true, false);
   }
}

If I show/hide that column several times, I observe that the grid looks each time differently. In particular column 15 (the one I hide/show) decrease its width constantly up to become very little after many show/hide.
It seems the grid is not recalculating properly its dimensions.

Is this a bug? Is there a better way to achieve the same result?

Thanks,
Luigi

[Updated on: Sat, 09 September 2017 21:34]

Report message to a moderator

Previous Topic: Change row appearance based on column value in that row
Next Topic: Header in body
Goto Forum:
  


Current Time: Fri Mar 29 12:00:39 CET 2024

Total time taken to generate the page: 0.01718 seconds