Select to view content in your preferred language

Checkbox and Radio Button Programming on GUI

2821
49
Jump to solution
02-20-2014 10:33 AM
MichelleCouden
Occasional Contributor
Am I on the right path here with my checkboxes and radio button programming. I have about three different checkboxes and a few radio button that I need to use in a If then statement. Unless, there is a simplier way of calling a layer using them...

private void checkBox1_Checked Changed(object sender, EventArgs e)

      If (checkboxstate.checked == true) Then
           If radioAtr.Enabled Then openFileDialog.InitialDirectory = "K:\"......

All help is extremely appreciated. Thanks!
0 Kudos
49 Replies
MichelleCouden1
Occasional Contributor III
This comes from a dialog box that opens when you open the mxd. You as the user check boxes to pull up the shapefile. For example, they want a map of the state of texas with all the manual traffic count stations on that map. Yeah, the only reason why I'm doing this in ArcObjects is because of the pretty dialog box my boss wants.
0 Kudos
LeoDonahue
Regular Contributor
You as the user check boxes to pull up the shapefile. For example, they want a map of the state of texas with all the manual traffic count stations on that map..


Yes, but, why do you want the user to check two things in order to load a single layer? 
You could easily name that checkbox: checkboxTexasManual
Now the user only needs to check one checkbox to get that layer to load.

I assume you have a GUI with several checkboxes from different states and each state has different options?  There are easier ways to present this to the user.
0 Kudos
MichelleCouden1
Occasional Contributor III
Yes, I'm sorry I thought I mentioned that on the first post. I have a GUI of many check boxes. They would choose between district or state and then they would choose between 8 to 9 different types of stations. So, for instance they might choose state and then choose ATR and Manual and AVC. So, yes this program is going to be a very long if then statement unles, I find out a simplier way.
0 Kudos
LeoDonahue
Regular Contributor
Great, then mark your post as the solution.
0 Kudos
MichelleCouden1
Occasional Contributor III
So, I take it I'm on the right track with the code below?

] If checkboxstate = true Then

If checkboxManual = true Then openFiledialog.InitialDirectory = "K:\......
0 Kudos
LeoDonahue
Regular Contributor
not really.
0 Kudos
MichelleCouden1
Occasional Contributor III
That's why I need help. Could you please direct me on how to get started. I don't think I will have trouble with the If then loop, once I get started. It's the arcObject language to use for the checkboxes.  Is it the checkbox commands I have wrong?  You mentioned an easier way. Is the If then loop the wrong program to use?
0 Kudos
KenBuja
MVP Esteemed Contributor
It might be easier for us to provide help if you post the image of your dialog box and a better explanation of your workflow.
0 Kudos
LeoDonahue
Regular Contributor
Is it the checkbox commands I have wrong?

I'd like to help you, trust me.  Unless your supervisor is dictating that you need a checkbox "and" a radio button to turn on a single layer, I don't see why you need to use both GUI components and perform a double boolean check to turn on a single layer.

I could see where maybe instead of checkboxes for States, you would use tabs, and then every checkbox on that State's tab would be related and you wouldn't need to use a radio button.

I also think you need to understand the difference between when to use a checkbox and when to use a radio button.

Radio Buttons - two or more mutually exclusive items, meaning you can only choose one of those mutually exclusive items at a time.

Checkbox - A Single checkbox is like a yes/no question - either you checked it or you didn't.  Grouped checkboxes can provided the user with the option to check multiple options.

So far, even when asked, you haven't provided information about why you want to use both GUI components.  And all I'm saying is that instead of this:

2 GUI components
[checkbox] texasCheckbox - [radio button] rdoManualTrafficCounts

you could do this:

1 GUI component
[checkbox] texasCheckboxForManualTrafficCounts

But I don't know what you are trying to do, so we go back and forth.
0 Kudos
MichelleCouden1
Occasional Contributor III
I'm sorry. I thought I was explaining myself. I am open to ideas on this project because of having to access so many different shapefiles for the user I really didn't want to write a ten page program with If then statements. I have attached a picture of my GUI that I have now. Let me try to explain our work here at TxDOT. We have about 6 different count machines. And our customers (i.e. the public) want maps to see where we do traffic counts. Now, they may need a variety of different stations. So, they may want a map with manual stations on it or a map of manual stations and ATR stations or they may want a map of manual, ATR, and classification stations. So, the maps can have a variety of stations and not just one station. Please let me know if this still does not make any sense. I think the tab idea is a good one. Like one tab for the state and one tab for each district in the state. Then on each tab there would be a checkbox for all the stations they have to choose from and then they can pick which stations they want on their map. I've also attached a word document of the tab idea.
0 Kudos