ScriptUO

Casa de TrailMyx => Programming / Operating Systems => Scripting Languages => Topic started by: Coragin on March 03, 2010, 10:22:02 PM

Title: VS 2008 C# Form Dropdown box Question.
Post by: Coragin on March 03, 2010, 10:22:02 PM
Okay so I have a dropdown box with two options.  Option1 and Option2.

I also have a control grid for each which is by default hidden unless the choose one of the two options.

If they choose option1, option1controls will appear.

If they choose option 2, option2controls will appear.

My question is, how do I set it to do that?  I highlight the dropdown list control, filter through all the options and cant seem to find the property stings I have in the list.  Or a way that if this one is selected, show this control if this one is selected show the other.

Secondly, I need a directory selection path, for the uo client files.  I have tried every control there is in VS2k8 forms and cant seem to find this one.

Finally anyone got a good site with documentation and "how to" with regards to forms?
Title: Re: VS 2008 C# Form Dropdown box Question.
Post by: TrailMyx on March 04, 2010, 03:48:40 AM
You'll spend a lot of time at MSDN looking through the docs.  :)
Title: Re: VS 2008 C# Form Dropdown box Question.
Post by: draxxter on March 04, 2010, 05:31:06 AM
Well i guess you mean DropDownList control. Then you need to hook your code in SelectedIndexChanged Event to hide/show the Grids.
With controlid.SelectedItem you get the ListItem, with controlid.SelectedValue you get the Item Value, etc etc.
Also you will need to have the grid for option 1 visible by default since option 1 will be already selected since you have only 2 options.
A work around is to add another item as a dummy something like "Nothing Selected...".


Not sure i got the selection path part of your question.

Title: Re: VS 2008 C# Form Dropdown box Question.
Post by: UOMaddog on March 05, 2010, 12:58:36 PM
It's all going to be done in the .cs file that is attached to that form.

Something along of the lines of:

Code: [Select]
if Dropdownboxid.option[0] == true
{
controls1id.visible = true;
}
if Dropdownboxid.option[1] == true
{
controls2id.visible = true;
}

that's not exact code since I don't know the exact id's of what you're doing, but it will look similar to that
Title: Re: VS 2008 C# Form Dropdown box Question.
Post by: Coragin on March 05, 2010, 01:03:49 PM
It's all going to be done in the .cs file that is attached to that form.

Something along of the lines of:

Code: [Select]
if Dropdownboxid.option[0] == true
{
controls1id.visible = true;
}
if Dropdownboxid.option[1] == true
{
controls2id.visible = true;
}

that's not exact code since I don't know the exact id's of what you're doing, but it will look similar to that

AH HA!  That is exactly what I needed.  If it dont work I will post, but thank you!!!  U DA MAN!
Title: Re: VS 2008 C# Form Dropdown box Question.
Post by: Endless Night on March 05, 2010, 01:13:49 PM
Dont forget to set the control not to be seen  visible property to false.

Title: Re: VS 2008 C# Form Dropdown box Question.
Post by: Coragin on March 05, 2010, 01:15:47 PM
Well didnt seem to work, this is what I put in, probably wrong syntax or wrong area...

Code: [Select]
       private void comboBoxResourceBot_SelectedIndexChanged(object sender, EventArgs e)

        {
            if comboBoxResourceBot.option[1] == true
            {
                groupBoxLumber.visable = true;
            }
        }
Title: Re: VS 2008 C# Form Dropdown box Question.
Post by: Coragin on March 05, 2010, 01:18:51 PM
If I can just figure out how to make things appear and disappear when other things are checked, be it drop own, radio or checkbox I can finish this menu.

Can anyone send me a source for a single form, with a drop down menu like that, and a control that will appear and disappear?

basicly have dropdown box with two options...

Show
Hide

And have even a pic appear, I dont care waht the object is, as long as I get an example lol.
Title: Re: VS 2008 C# Form Dropdown box Question.
Post by: UOMaddog on March 05, 2010, 01:29:37 PM
First off, let VS auto-complete for you. If it doesn't bring up what you want, then you have the wrong syntax.

In this case, it should be ".Visible" not ".visable" There could be more problems with it than that though
Title: Re: VS 2008 C# Form Dropdown box Question.
Post by: UOMaddog on March 05, 2010, 01:30:21 PM
http://msdn.microsoft.com/en-us/library/system.windows.forms.control.visible.aspx
Title: Re: VS 2008 C# Form Dropdown box Question.
Post by: Coragin on March 05, 2010, 01:30:46 PM
I think what I am doing wrong here is I am adding items to the drop down list, however, no variables of said items?  Possibly?
Title: Re: VS 2008 C# Form Dropdown box Question.
Post by: Coragin on March 05, 2010, 01:32:53 PM
Okay that link explains that, need to mess around mroe I think.  And I caught the spelling error...
Title: Re: VS 2008 C# Form Dropdown box Question.
Post by: Coragin on March 05, 2010, 01:46:41 PM
Okay here is my test form.

It has a drop down list with "Show" and "Hide" in the list along with a labeled "Layout Panel" Set to hide.  So when show is selected, I need to make that panel show.
Title: Re: VS 2008 C# Form Dropdown box Question.
Post by: draxxter on March 08, 2010, 12:17:58 AM
Code: [Select]
        private void comboBox1_SelectedIndexChanged(object sender, EventArgs e)
        {
            if ((string) comboBox1.SelectedItem == "Hide")
            {
                label1.Visible = false;
            }
            if ((string) comboBox1.SelectedItem == "Show")
            {
                label1.Visible = true;
            }
        }

Also assign the event in design mode or in Form constructor with
Code: [Select]
comboBox1.SelectedIndexChanged+=comboBox1_SelectedIndexChanged;

Hope i helped.
Title: Re: VS 2008 C# Form Dropdown box Question.
Post by: Coragin on March 08, 2010, 05:37:24 AM
Thanks Draxxter, UOOMD helped me with this, but we used numbers 0-9 ect instead of the words of the selection, I didnt know you could do that.  Good to know, thank you.  You must know C# pretty well huh?
Title: Re: VS 2008 C# Form Dropdown box Question.
Post by: draxxter on March 08, 2010, 10:21:20 PM
hehe. Web App C# Developer my job description. :) Glad i could help you. :)
Title: Re: VS 2008 C# Form Dropdown box Question.
Post by: Coragin on March 08, 2010, 10:56:39 PM
hehe. Web App C# Developer my job description. :) Glad i could help you. :)

why havent you joined the uoboost project?  lol
Title: Re: VS 2008 C# Form Dropdown box Question.
Post by: draxxter on March 09, 2010, 02:55:33 AM
I was tempted but my free time is already limited and my wife would start kicking my butt :P.
Title: Re: VS 2008 C# Form Dropdown box Question.
Post by: Coragin on March 09, 2010, 07:42:42 AM
I was tempted but my free time is already limited and my wife would start kicking my butt :P.

I hear ya.  Cept on the wife part ;)  rofl  But I know how a GF can be
Title: Re: VS 2008 C# Form Dropdown box Question.
Post by: draxxter on March 10, 2010, 01:36:34 AM
Ask if you need anything else, will try to help as always. :)
Title: Re: VS 2008 C# Form Dropdown box Question.
Post by: Coragin on March 10, 2010, 06:42:52 AM
I just made a new post entitled why would microsoft do this.  It asks for two examples.  ;)