1 Replies - 1761 Views - Last Post: 27 May 2010 - 10:04 AM Rate Topic: -----

#1 Guest_JoseTlaseca*


Reputation:

How can i get an combobox selected value?

Posted 27 May 2010 - 09:58 AM

Hi everyone!!!
I am new in this forum and in c# programming and i have a little problem, i was wondering if somer one can help me. This is the problem i have:

I got a function that access to some fields values and use them to perform a sum or some other operation.
I can access to string fields, int fields, etc, but now i need to get the selected value from a combobox, and i dont know how to do that.
This is what i have:

public void calcularFechaVigencia( )
{
	IRuntimeObject tramite = (IRuntimeObject)this;//with this i can access to local fields
	IRuntimeObject CL_E = (IRuntimeObject)tramite["checklist_Especificas"];//with this i can access to the fields of an external object
        //I use a field named "checklist_Especificas" that is a link field to the needed object.
	IRuntimeObject CL_Ma = (IRuntimeObject)tramite["Checklist_Mayores"];//The same here
	IRuntimeObject TT = (IRuntimeObject)tramite["TipodeTramite"];//and here
	
	double num_dias = 0;
	
    if( CL_E["textbox_vigencia_NoDias"] != null )
    {
        num_dias = (Convert.ToDouble(CL_E["textbox_vigencia_NoDias"]) + Convert.ToDouble(TT["Vigencia"]));
        //here i take one field from one object and one from another and sum them, this works fine.
    }
	
    if( CL_Ma["selectlist_vigencia_noDias"] != null )
    {
        //but here, the field "selectlist_vigencia_noDias" is a combobox, and when i try to do that sum i got an "Object reference to an instance of an object" error
        num_dias = combobox1.GetAllowedValues(//(Convert.ToDouble(CL_Ma["selectlist_vigencia_noDias"]) + Convert.ToDouble(TT["Vigencia"]));
        //I think i need to use a method to access that value, like SelectedItem or something, but i dont know how.
    }
	
    tramite["FechaVigencia"] = DateTime.Now.AddDays(num_dias); //Here i save the result on a local field.
}




Hope some one have the time and can help me.... anyway thank you very much...

This post has been edited by JackOfAllTrades: 27 May 2010 - 10:16 AM
Reason for edit:: Added code tags.


Is This A Good Question/Topic? 0

Replies To: How can i get an combobox selected value?

#2 Guest_JoseTlaseca*


Reputation:

Re: How can i get an combobox selected value?

Posted 27 May 2010 - 10:04 AM

Hi again...

Sorry, i made a mistake.

When i wrote:
num_dias = combobox1.GetAllowedValues(//(Convert.ToDouble(CL_Ma["selectlist_vigencia_noDias"]) + Convert.ToDouble(TT["Vigencia"]));


must be:
num_dias = (Convert.ToDouble(CL_Ma["selectlist_vigencia_noDias"]) + Convert.ToDouble(TT["Vigencia"]));

Sorry

This post has been edited by JackOfAllTrades: 27 May 2010 - 10:16 AM

Was This Post Helpful? 0

Page 1 of 1