473,396 Members | 2,014 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,396 software developers and data experts.

Change combobox value

Fellow csharpers..

I got a problem that I haven't found a solution for, and are hoping to get some help.

I have the following piece of code (with commented out parts that I tried without success)
Hoping someone can help me.

Expand|Select|Wrap|Line Numbers
  1. else if (msg[0].ToString() == "set")
  2.                     {
  3.                         MessageBox.Show(msg[0].ToString());
  4.                         if (msg[1].ToString() == "master")
  5.                         {
  6.                             MessageBox.Show(msg[1].ToString());
  7.                             int num;
  8.                             if (Int32.TryParse(msg[2], out num))
  9.                             {
  10.                                 int NMasters = MasterBox.Items.Count;
  11.                                 MessageBox.Show(NMasters.ToString());
  12.                                 if (num < 1)
  13.                                 {
  14.                                     Client.Self.InstantMessage(e.IM.FromAgentID, "[ERROR]: Invalid number (lower than NMasters), please try again!");
  15.                                 }
  16.                                 else if (num > NMasters)
  17.                                 {
  18.                                     Client.Self.InstantMessage(e.IM.FromAgentID, "[ERROR]: Invalid number (Higher than NMasters), please try again!");
  19.                                 }
  20.                                 else
  21.                                 {
  22.                                     MessageBox.Show("MEH");
  23.                                     MasterBox.Select(num, num);
  24.                                     //MasterBox.DroppedDown = true;
  25.                                     //MasterBox.SelectedItem = num;
  26.                                     //MasterBox.DroppedDown = false;
  27.                                     //MasterName = MasterBox.SelectedItem.ToString();
  28.                                     //GetMKey();
  29.                                 }
  30.                             }
  31.                         }
  32.                     }
  33.  
Everything is working, up until where I want the combobox (MasterBox) to change.
The command "set master X" is supposed to change the selected item inside the combobox, but whatever I try won't work.

Is it possible at all to do it the way I am trying to? Or do I have to re-think it all?

I am not too good (yet) with Csharp, so hopefully someone can point me in the right direction.

Thank you all!
Sep 7 '10 #1
1 3033
Im not sure I exactly get what you're trying to do, but how about:

Expand|Select|Wrap|Line Numbers
  1. MasterBox.SelectedIndex = num - 1
Sep 14 '10 #2

Sign in to post your reply or Sign up for a free account.

Similar topics

8
by: Matt Herson | last post by:
I have been trying to find a way to use JavaScript to change the value of a hidden field on submit. I am already invoking a JavaScript to handle the validation on submit. The reason I need to...
0
by: Daniel | last post by:
how to change the value of Request.ServerVariables on the ser ver? if not possible is there some way to change it by sending back javascript to the client and having the client automaticaly do...
2
by: Rick | last post by:
I have an XML document that is generated from Infopath, I need to change the value of a namespace that is defined in a node in the form: <xsf:xDocumentClass "xmlns:my=valuehere">. when i navigate...
9
by: juli jul | last post by:
Hello ,I am trying to get the comboBox value but when I am writing: MessageBox.Show(this.comboBoxdb.SelectedValue.ToString()); I get the following result: System.Data.DataRowView instead of the...
4
by: Anson | last post by:
Dear all, This questions seems simple to most of you, but I just couldn't figure it out. I have a combobox. I want to capture the value (or index) of the combo box just **before** the user...
0
by: zhuang | last post by:
Hi, Adding combobox to datagrid has been posted many times. I have a datagrid which has multiple combobox columns and normal textbox columns. But how could I change other combo box values at...
5
by: Rex | last post by:
Hi, I want to change a value in one table depending on the value(s) in another table. I am trying to achieve this in a form. to elaborate I have a many-to-many relationship between tables...
3
by: rhepsi | last post by:
Hii all, How to join two tables and a combobox value?? i have 2 combo boxes and 2 tables i have aquery: 1) Dim myselectquery As String = "SELECT pr_project_id_pk FROM tbl_projects WHERE...
2
by: nisha chaudhary | last post by:
i am using a jsp page and trying to change the value of one combobox onchange in value of another. the value should be retrieved from a database.how i can do this using ajax in jsp page
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.