| 
 | 
 | 
 
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   | 
		 
		
			
				
				
				  | 
					
						  
						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 #14644 is a reply to message #14616] | 
			Wed, 05 March 2008 19:11    | 
		 
		
			
				
				
				  | 
					
						  
						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?   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!!     
 
Any direction Mirek to help debugging?  
 
Thx! 
Hernan 
 
 
 
 
 
 
 
		
		
		[Updated on: Wed, 05 March 2008 19:18] Report message to a moderator  
 |  
	| 
		
	 | 
 
 
 |  
	| 
		
 |  
	| 
		
 |   
Goto Forum:
 
 Current Time: Tue Nov 04 08:26:00 CET 2025 
 Total time taken to generate the page: 0.05161 seconds 
 |   
 |  
  |