Click here to Skip to main content
15,897,147 members

C# Radio Button Status to call Class

mphill4744 asked:

Open original thread
Please bear with me, I am coming from a VB environment to Visual C# (2010 express).
I am having a problem with understanding how to call a class if a radio button is checked then a cmdRun_Click is pressed. Can it be called/instantiated this way?

See the else if (rdoBDS.Checked) line.

namespace WindowsFormsApplication1
{
    public partial class Form1 : Form
    {

        public Form1()
        {
            InitializeComponent();
            //_items.Add("MicroStation");
            //_items.Add("Road");
            //_items.Add("Photo");
            //_items.Add("Field");
            //_items.Add("BDS");

            //listBox1.DataSource = _items;
        }
        private void cmdExit_Click(object sender, EventArgs e)
        {
            this.Close();
        }

        List<string> _items = new List<string>();

        private void cmdRun_Click(object sender, EventArgs e)
        {
            if (rdoMicroStation.Checked)
                _items.Add("MicroStation - Edit Icon Properties to switch departments, Bridge is the default.");

            //MessageBox.Show("Mstn Selected");
            else if (rdoRoad.Checked)
                _items.Add("Road Design Icons V7V8, V8, and Modeler");

            else if (rdoPhotoSurvey.Checked)
                _items.Add("Photos and Survey Icons V7V8, V8 and Land Surveyor");

            else if (rdoField.Checked)
                _items.Add("Field = Road and Photo-Survey and Land Surveyor Icons");

            else if (rdoBDS.Checked)
                _items.Add("Bridge Deck Survey Icons and database setup");
            BridgeDeckSurvey bdsstuff = new BridgeDeckSurvey();

            listBox1.DataSource = _items;
            //Change the DataSource
            listBox1.DataSource = null;
            listBox1.DataSource = _items;
        }

        private void rdoBDS_CheckedChanged(object sender, EventArgs e)
        {

        }

    }
}

public class BridgeDeckSurvey

{
    public static void BDSReg(string[] args)
    {
        string filePath = "O:\\cad_std\\configs\\_Select_A_setup\\Setup_08_11_XP_Win7\\bds_odbc_xp.reg";
        System.Diagnostics.Process proc = new System.Diagnostics.Process();
        proc.EnableRaisingEvents = false;
        proc.StartInfo.FileName = filePath;
        proc.Start();
        goto AppendIni;

    AppendIni:
        try
        {
            StreamWriter sw = new StreamWriter("C:\\Windows\\odbc.ini");
            sw.WriteLine("BDS=Microsoft Access Driver (*.mdb, *.accdb) (32 bit)");
            sw.Close();
        }
        catch (IOException e)
        {
            Console.WriteLine("An IO Exception Occurred:" + e.Message);
        }
        finally
        {
            Console.WriteLine("Finished");
        }
    }

}
Tags: C# (C# 4.0)

Plain Text
ASM
ASP
ASP.NET
BASIC
BAT
C#
C++
COBOL
CoffeeScript
CSS
Dart
dbase
F#
FORTRAN
HTML
Java
Javascript
Kotlin
Lua
MIDL
MSIL
ObjectiveC
Pascal
PERL
PHP
PowerShell
Python
Razor
Ruby
Scala
Shell
SLN
SQL
Swift
T4
Terminal
TypeScript
VB
VBScript
XML
YAML

Preview



When answering a question please:
  1. Read the question carefully.
  2. Understand that English isn't everyone's first language so be lenient of bad spelling and grammar.
  3. If a question is poorly phrased then either ask for clarification, ignore it, or edit the question and fix the problem. Insults are not welcome.
  4. Don't tell someone to read the manual. Chances are they have and don't get it. Provide an answer or move on to the next question.
Let's work to help developers, not make them feel stupid.
Please note that all posts will be submitted under the http://www.codeproject.com/info/cpol10.aspx.



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900