C# Are combo boxes broken in C#?

Discussions concerning programming of SOFTIMAGE©
Post Reply
User avatar
redmotion
Posts: 150
Joined: 09 Jun 2009, 18:38
Location: London
Contact:

C# Are combo boxes broken in C#?

Post by redmotion » 19 Sep 2009, 12:18

I can't get a value from a combobox.

In the section

Code: Select all

 else if (eventID == siPPGEventID.siParameterChange)
        {
of the property I've got:

Code: Select all

 if (paramName == "Timezone")
            {
                int pv = (int)paramValue; //cast to int from object here
                string tz = TimeZoneList1[pv];
                //update the timezone name with exe scriptcommand
                object[] args_tz = new object[3] { Rootername + ".Timezonename", tz, null };
                app.ExecuteScriptCommand("SetValue", args_tz);
            }
For getting a value from a slider and setting textbox contents based on it. This works perfectly fine.

But doing similar for a combobox with:

Code: Select all

            if (paramName == "City")
            {
                app.LogMessage("City changed!", siSeverity.siInfo);
                int pvc = (int)paramValue; //cast to int from object here
                //app.LogMessage("City selected: " + pvc, siSeverity.siInfo);
                //int pvc = 2;
                double lg = citylong[pvc];
                double lt = citylati[pvc];
                int tz = citytmzones[pvc];
                object[] args_tz11 = new object[3] { Rootername + ".Longitude", lg, null };
                app.ExecuteScriptCommand("SetValue", args_tz11);
                object[] args_tz10 = new object[3] { Rootername + ".Latitude", lt, null };
                app.ExecuteScriptCommand("SetValue", args_tz10);
                object[] args_tz12 = new object[3] { Rootername + ".Timezone", tz, null };
                app.ExecuteScriptCommand("SetValue", args_tz12);
                object[] args_tz13 = new object[3] { Rootername + ".Timezonename", tz, null };
                app.ExecuteScriptCommand("SetValue", args_tz13);
            }
Doesn't work. The cast "int pvc = (int)paramValue;" just doesn't work in this case. If I uncomment the int pvc = 2; line I can set the values with no problem. So it must be the line that casts to an object to an int thats broken.

Help!! ~x(

Post Reply

Who is online

Users browsing this forum: No registered users and 17 guests