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 » GridCtrl: Setting column widths programmatically
GridCtrl: Setting column widths programmatically [message #35433] Tue, 14 February 2012 04:56 Go to next message
Lance is currently offline  Lance
Messages: 526
Registered: March 2007
Contributor
See attached program.

When column width allocation mode is absolute, there is no problem. When it's proportional, first time it works, but not subsequent ones. Supplied column widths don't seem to take effect.

Is there some steps I missed?

Thanks!

[Updated on: Tue, 14 February 2012 04:57]

Report message to a moderator

Re: GridCtrl: Setting column widths programmatically [message #35434 is a reply to message #35433] Tue, 14 February 2012 05:10 Go to previous messageGo to next message
Lance is currently offline  Lance
Messages: 526
Registered: March 2007
Contributor
When the SetColumns() is called from App constructor (which is derived from TopWindow), it produce a decent and desired result like this:
index.php?t=getfile&id=3658&private=0

Click the buttom to invoke SetColumns for more times, something like this is produced:
index.php?t=getfile&id=3659&private=0

Re: GridCtrl: Setting column widths programmatically [message #35435 is a reply to message #35434] Tue, 14 February 2012 05:12 Go to previous messageGo to next message
Lance is currently offline  Lance
Messages: 526
Registered: March 2007
Contributor
Source code of test program in case you don't want to download it.
#include <CtrlLib/CtrlLib.h>
#include <GridCtrl/GridCtrl.h>


using namespace Upp;

class App: public TopWindow
{
public:
	App()
	{
		b.SetLabel("Random # of Columns").LeftPosZ(2, 250).TopPosZ(2,30);
		o.SetLabel("Proportional").LeftPosZ(260, 150).TopPosZ(2,30);
		o.SetData(true);
		grid.HSizePosZ(2,2).VSizePosZ(35,2);
		Add(b);
		Add(grid);
		Add(o);
		
		b<<=THISBACK(SetColumns);
		o<<=THISBACK(OptionClicked);
		SetColumns();
	}
private:
	void SetColumns()
	{
		dword c=::Random();
		c=5+c%4;
		grid.Clear(true);
		for(dword i=0; i<c; ++i)
		{
			grid.AddColumn(String().Cat()<<"Column "<<i, 50);
		}
	}
	
	void OptionClicked()
	{
		if(o.GetData()==true)
			grid.Proportional();
		else
			grid.Absolute();
	}

	Button b;
	Option o;
	
	GridCtrl grid;
	
	typedef App CLASSNAME;
};

GUI_APP_MAIN
{
		App().Title("Grid Column Width").Sizeable().Run();
}
Re: GridCtrl: Setting column widths programmatically [message #35436 is a reply to message #35435] Tue, 14 February 2012 07:33 Go to previous messageGo to next message
unodgs is currently offline  unodgs
Messages: 1366
Registered: November 2005
Location: Poland
Ultimate Contributor

Hi Lance!
I described solution for this problem many times Smile (that only means that current behavior is not intuitive and cumbersome..). Your SetColumns method should look like this:
	void SetColumns()
	{
		dword c=::Random();
		c=5+c%4;
                grid.Ready(false);
		grid.Clear(true);
		for(dword i=0; i<c; ++i)
		{
			grid.AddColumn(String().Cat()<<"Column "<<i, 50);
		}
                grid.Ready(true);
	}
	
Re: GridCtrl: Setting column widths programmatically [message #35438 is a reply to message #35436] Tue, 14 February 2012 15:05 Go to previous message
Lance is currently offline  Lance
Messages: 526
Registered: March 2007
Contributor
Thank you! I indeed did a search but failed to discover any thing relevant. Maybe you can insert a comment/document for one of the set-column-width methods?
Previous Topic: GridCtrl: Sorting order
Next Topic: GridCtrl: how to show the last inserted row
Goto Forum:
  


Current Time: Thu Mar 28 13:27:27 CET 2024

Total time taken to generate the page: 0.01783 seconds