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 » Simpler way to access Option in GridCtrl
Simpler way to access Option in GridCtrl [message #31987] Thu, 14 April 2011 10:34 Go to next message
koldo is currently offline  koldo
Messages: 3004
Registered: August 2008
Ultimate Member
Hello Daniel

Option() method is very nice but it is not possible to get access to the underlying control (for example to set a WhenAction()).

To get that possibility when adding a row I have to do this:
while(SQL.Fetch()) {						// Loop for all fetched data
	grid.Add();						// Added new row
	for (int i = 0; i < fields.GetCount(); ++i) {		// For all fields
		sqlBase.grid(i) = SQL[i];			// Filling with data
		if (column is Option) {				// THIS HAVE TO BE DONE FOR ALL ROWS
			Option *opt = new Option();		// new Option()
			opt->WhenAction = THISBACK(MyCallback);	// Set the callback to the control
			sqlBase.grid.SetCtrl(i, opt);	 	// Set the control to the cell
		}
	}
}


Is there any simpler possibility?


Best regards
Iñaki
Re: Simpler way to access Option in GridCtrl [message #31988 is a reply to message #31987] Thu, 14 April 2011 13:36 Go to previous messageGo to next message
unodgs is currently offline  unodgs
Messages: 1354
Registered: November 2005
Location: Poland
Senior Contributor

Yes, there is Smile
There is WhenCtrlAction and WhenCtrlsAction. First is called for every embedded control if there was leftdown righdown or mousewheel action. Second is called for every kind of action for controls that where created automatically for column (by for example using Option() method). You can use it like this:
grid.WhenCtrlsAction = THISBACK(ShowCtrlValue);

void ShowCtrlValue()
{
    PromptOK(AsString(grid.Get()));
}
Re: Simpler way to access Option in GridCtrl [message #31989 is a reply to message #31988] Thu, 14 April 2011 16:01 Go to previous messageGo to next message
koldo is currently offline  koldo
Messages: 3004
Registered: August 2008
Ultimate Member
Hello Daniel

Your answer is almost perfect Smile.

However if grid.Editing(false), the Option cells remain editable and look as editable Sad.


Best regards
Iñaki
Re: Simpler way to access Option in GridCtrl [message #32768 is a reply to message #31989] Tue, 07 June 2011 08:31 Go to previous messageGo to next message
unodgs is currently offline  unodgs
Messages: 1354
Registered: November 2005
Location: Poland
Senior Contributor

koldo wrote on Thu, 14 April 2011 10:01

Hello Daniel

Your answer is almost perfect Smile.

However if grid.Editing(false), the Option cells remain editable and look as editable Sad.

Sorry for not responding so long. You're right - this is wrong behavior. I'll fix that.
Re: Simpler way to access Option in GridCtrl [message #32769 is a reply to message #32768] Tue, 07 June 2011 09:38 Go to previous message
koldo is currently offline  koldo
Messages: 3004
Registered: August 2008
Ultimate Member
Excellent Daniel Smile

Please send a message after uploading the fix.


Best regards
Iñaki
Previous Topic: FIX: ArrayCtrl to support Style
Next Topic: GridCtrl: detecting a change of a search string
Goto Forum:
  


Current Time: Sat Oct 19 03:48:33 CEST 2019

Total time taken to generate the page: 0.01567 seconds