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 » U++ Widgets - General questions or Mixed problems » Can't set value in switch with EnableValue
Can't set value in switch with EnableValue [message #14557] Mon, 03 March 2008 19:09 Go to next message
indiocolifa is currently offline  indiocolifa
Messages: 49
Registered: January 2008
Location: Argentina
Member
I'm trying to set a switch option from a database which stores an string (which is the value for the switch as I set them first).

This is the code:

UserEditWindow::UserEditWindow(String sel)
{
	CtrlLayout(*this, sel == "" ? "Nuevo Usuario" : "Editar Usuario " + sel);
	
	pwd.Password(true);
	optUserClass.Set(0, "ROOT", "Root (Administrador, privilegios totales)");
	optUserClass.Set(1, "FULL", "Full (Usuario completo, puede realizar altas)");
	optUserClass.Set(2, "CONSULTA", "Consulta (Restringido a realizar consultas)");
	
	if (sel == "")
	{
		editing = false;
		optUserClass.EnableValue("ROOT");
	}
	else
	{
		editing = true;
		
		// llenar campos 
		
		Sql sql((*(G_STATE->GetPsqlSession())));
		loginName = sel;
		realName.SetData(sql % Select(NOMBRE).From(OPERADOR).Where(LOGIN == sel));
		pwd.SetData(sql % Select(PASSWORD).From(OPERADOR).Where(LOGIN == sel));
		optUserClass.EnableValue(sql % Select(CLASE).From(OPERADOR).Where(LOGIN == sel));
	}
	
	// registra callbacks
	
	btnCancel.WhenAction = THISBACK(Close);
	btnOk.WhenAction = THISBACK(Save);
}


The line:


optUserClass.EnableValue(sql % Select(CLASE).From(OPERADOR).Where(LOGIN == sel));

it's where where the data is retrieved from the DB to set the switch value (and I retrieve the correct data, strings such as ROOT,FULL,CONSULTA are taken OK from the DB table).

I don't know why this does not work, since i'm setting the related values-text at first.

Thx for your help.


[Updated on: Mon, 03 March 2008 19:10]

Report message to a moderator

Re: Can't set value in switch with EnableValue [message #14565 is a reply to message #14557] Mon, 03 March 2008 20:16 Go to previous messageGo to next message
mirek is currently offline  mirek
Messages: 14105
Registered: November 2005
Ultimate Member
Hard to say, I see nothing obvious. Try to put:

DUMP(sql % Select(CLASE).From(OPERADOR).Where(LOGIN == sel))

before that line (and report what it says in .log - press Alt+L in 2008 theide).

Mirek
Re: Can't set value in switch with EnableValue [message #14597 is a reply to message #14565] Tue, 04 March 2008 13:38 Go to previous messageGo to next message
indiocolifa is currently offline  indiocolifa
Messages: 49
Registered: January 2008
Location: Argentina
Member
Here's the log output:
* C:\upp\out\MSC9.Debug_full.Gui\sr2k8.exe 04.03.2008 10:32:43, user: Administrador

sql % Select(CLASE).From(OPERADOR).Where(LOGIN == sel) = CONSULTA


And CONSULTA is a value for the switch...

This is a bug in U++?

I'm using UPP 2008.1 beta.

Thx!

[Updated on: Tue, 04 March 2008 13:46]

Report message to a moderator

Re: Can't set value in switch with EnableValue [message #14616 is a reply to message #14597] Tue, 04 March 2008 17:15 Go to previous messageGo to next message
mirek is currently offline  mirek
Messages: 14105
Registered: November 2005
Ultimate Member
I have tested with this simple testcase:

#include <CtrlLib/CtrlLib.h>

using namespace Upp;

GUI_APP_MAIN
{
	TopWindow win;
	Switch h;
	h.Add("One", "One");
	h.Add("Two", "Two");
	h.Add("Three", "Three");
	h.EnableValue("One", false);
	h.EnableValue("Two", false);
	win.Add(h.SizePos());
	win.Run();
	h.EnableValue("Two", true);
	win.Run();
}



and it seems to work OK.

Is not it possible that there is a space after the CONSULTA? Smile Or something like that.

You might also try to place .EnableValue("CONSULTA") instead of using Select to test it...

Mirek
Re: Can't set value in switch with EnableValue [message #14644 is a reply to message #14616] Wed, 05 March 2008 19:11 Go to previous messageGo to next message
indiocolifa is currently offline  indiocolifa
Messages: 49
Registered: January 2008
Location: Argentina
Member
luzr wrote on Tue, 04 March 2008 14:15

I have tested with this simple testcase:

#include <CtrlLib/CtrlLib.h>

using namespace Upp;

GUI_APP_MAIN
{
	TopWindow win;
	Switch h;
	h.Add("One", "One");
	h.Add("Two", "Two");
	h.Add("Three", "Three");
	h.EnableValue("One", false);
	h.EnableValue("Two", false);
	win.Add(h.SizePos());
	win.Run();
	h.EnableValue("Two", true);
	win.Run();
}



and it seems to work OK.

Is not it possible that there is a space after the CONSULTA? Smile Or something like that.

You might also try to place .EnableValue("CONSULTA") instead of using Select to test it...

Mirek


Hey Mirek, I tried to manually set the switch value ... and DOES NOT WORKS!!! żż?? This is RARE.

Look:

UserEditWindow::UserEditWindow(String sel)
{
	CtrlLayout(*this, sel == "" ? "Nuevo Usuario" : "Editar Usuario " + sel);
	
	pwd.Password(true);
	optUserClass.Set(0, "ROOT", "Root (Administrador, privilegios totales)");
	optUserClass.Set(1, "FULL", "Full (Usuario completo, puede realizar altas)");
	optUserClass.Set(2, "CONSULTA", "Consulta (Restringido a realizar consultas)");
	
	if (sel == "")
	{
		editing = false;
		optUserClass.EnableValue("ROOT");
	}
	else
	{
		editing = true;
		
		// llenar campos 
		
		Sql sql((*(G_STATE->GetPsqlSession())));
		loginName = sel;
		realName.SetData(sql % Select(NOMBRE).From(OPERADOR).Where(LOGIN == sel));
		pwd.SetData(sql % Select(PASSWORD).From(OPERADOR).Where(LOGIN == sel));
		optUserClass.EnableValue("CONSULTA");
		/*optUserClass.EnableValue(sql % Select(CLASE).From(OPERADOR).Where(LOGIN == sel));*/
	}
	
	// registra callbacks
	
	btnCancel.WhenAction = THISBACK(Close);
	btnOk.WhenAction = THISBACK(Save);
}


See that I've commented out taking the value from the DB table.
I simply did:

optUserClass.EnableValue("CONSULTA");


Which is properly set at constructor with:

optUserClass.Set(2, "CONSULTA", "Consulta (Restringido a realizar consultas)");


After the manual Enablevalue, I tested with:

DUMP(optUserClass.GetData())


and I get..

optUserClass.GetData() = ROOT


My god!! Laughing

Any direction Mirek to help debugging?

Thx!
Hernan







[Updated on: Wed, 05 March 2008 19:18]

Report message to a moderator

Re: Can't set value in switch with EnableValue [message #14649 is a reply to message #14644] Wed, 05 March 2008 20:21 Go to previous messageGo to next message
mrjt is currently offline  mrjt
Messages: 705
Registered: March 2007
Location: London
Contributor
I think the problem is that you have misunderstood what EnableValue does. It is actually for Enabling/Disableing (greying out) an option. Try changing EnableValue to DisableValue and you will see what I mean.

If you want to set the selected option use SetData or the <<= operator.
ie:
optUserClass <<= "CONSULTA"

Re: Can't set value in switch with EnableValue [message #14650 is a reply to message #14649] Wed, 05 March 2008 20:37 Go to previous message
indiocolifa is currently offline  indiocolifa
Messages: 49
Registered: January 2008
Location: Argentina
Member
I will try that tomorrow, thanks! Very Happy
Previous Topic: Images in menus causing enormous padding
Next Topic: How to modify Page setup (left margin) in RichText Control
Goto Forum:
  


Current Time: Thu Oct 31 23:48:21 CET 2024

Total time taken to generate the page: 0.01663 seconds