Hii All.
First I will like to tell a little about my self.
I'm a new Datatechnical apprentice and work right now on a front-line support department, but shortly I will move on to the Development department.
I'm currently working on a C# form application project, where I need to make a Form applicaiton using a SQL database and a Website (ASP) using a SQL database with C# code behind.
Now, im stuck for the first time, with a Switch-case statement where i'm using a if-else statement to do something if true.
LoL
The problem is, that I maked a new form, where i'm using a comboBox to show many diffrent links. You press the comboBox, and it will show down some links, but the problem is, when i'm from the Baseform open the frmLink form, then it opens the website before I actually have chosen one. I'm using enums, and why i'm doing that is because I saw it from this link:
http://blog.kayesd.com/?p=36[
^], and I really like the mode he is using them, but maybe it could also be that I had misunderstood the why that wee actually should use them?
These are the three diffrent website its open:
case links_auto.Mercedes_Benz_Herlev:
Process.Start(new ProcessStartInfo("iexplore", Link_Mercedes_Benz_Herlev));
break;
case links_forhandler.Mercedes_Benz:
Process.Start(new ProcessStartInfo("iexplore", Link_Mercedes_Benz));
break;
case links_Reservedel.Mekonomen:
Process.Start(new ProcessStartInfo("iexplore", Link_Mekonomen));
break;
I no that the reason why it ceeps openning them, is because the are on the list already whem I open the frmLink form.
(and this is olso a fail, but i'm also not able to remove them??)
I then, chosen to use a If-else statement to say, if I chose this website, then open it, and if I have chosen the other one, then do that, so they wont open as I open the frmLink form, but i fails all the time.
Like this:
private void comboBox3_SelectedIndexChanged(object sender, EventArgs e)
{
if (links_Reservedel.Mekonomen || links_Reservedel.Mekonomen = true)
{
switch ((links_Reservedel)comboBox3.SelectedItem)
{
case links_Reservedel.Mekonomen:
Process.Start(new ProcessStartInfo("iexplore", Link_Mekonomen));
break;
case links_Reservedel.Thansen:
Process.Start(new ProcessStartInfo("iexplore", Link_Thansen));
break;
}
}
}
The complete soruce code without the if-else statement is here:
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Diagnostics;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
namespace Benzin_maaler.MenuLinje.MenuTools
{
public partial class frmlinks : Form
{
private string Link_Mercedes_Benz_Herlev = "http://www.mercedes-benz.dk/applications/dialog/";
private string Link_BMW_Terminalen_Brøndby = "http://www.terminalen.dk/terminalerne/koebenhavn/default.aspx";
private string Link_VW_Glostrup = "http://vw.autohuset-glostrup.dk/";
private string Link_Audi_Glostrup = "http://audi.autohuset-glostrup.dk/";
private string Link_Mercedes_Benz = "http://www2.mercedes-benz.dk";
private string Link_Bmw = "http://www.bmw.dk";
private string Link_Audi = "http://www.audi.dk";
private string Link_Ford = "http://www.ford.com/";
private string Link_VW = "http://www.vw.com/en.html";
private string Link_Opel = "http://www.opel.dk/flash.html";
private string Link_Thansen = "http://www.thansen.dk/";
private string Link_Mekonomen = "http://www.mekonomen.dk/";
private enum links_auto
{
Mercedes_Benz_Herlev, BMW_Terminalen_Brøndby, VW_Glostrup, Audi_Glostrup
}
private enum links_forhandler
{
Mercedes_Benz, BMW, Audi, Ford, Opel, VW
}
private enum links_Reservedel
{
Thansen, Mekonomen
}
private enum links_div
{
}
public frmlinks()
{
InitializeComponent();
comboBox1.DataSource = Enum.GetValues(typeof(links_auto));
comboBox2.DataSource = Enum.GetValues(typeof(links_forhandler));
comboBox3.DataSource = Enum.GetValues(typeof(links_Reservedel));
comboBox4.DataSource = Enum.GetValues(typeof(links_div));
}
private void comboBox1_SelectedIndexChanged(object sender, EventArgs e)
{
switch ((links_auto)comboBox1.SelectedItem)
{
case links_auto.Mercedes_Benz_Herlev:
Process.Start(new ProcessStartInfo("iexplore", Link_Mercedes_Benz_Herlev));
break;
case links_auto.BMW_Terminalen_Brøndby:
Process.Start(new ProcessStartInfo("iexplore", Link_BMW_Terminalen_Brøndby));
break;
case links_auto.Audi_Glostrup:
Process.Start(new ProcessStartInfo("iexplore", Link_Audi_Glostrup));
break;
case links_auto.VW_Glostrup:
Process.Start(new ProcessStartInfo("iexplore", Link_VW_Glostrup));
break;
}
}
private void comboBox2_SelectedIndexChanged(object sender, EventArgs e)
{
switch ((links_forhandler)comboBox2.SelectedItem)
{
case links_forhandler.Mercedes_Benz:
Process.Start(new ProcessStartInfo("iexplore", Link_Mercedes_Benz));
break;
case links_forhandler.BMW:
Process.Start(new ProcessStartInfo("iexplore", Link_Bmw));
break;
case links_forhandler.Audi:
Process.Start(new ProcessStartInfo("iexplore", Link_Audi));
break;
case links_forhandler.Ford:
Process.Start(new ProcessStartInfo("iexplore", Link_Ford));
break;
case links_forhandler.VW:
Process.Start(new ProcessStartInfo("iexplore", Link_VW));
break;
case links_forhandler.Opel:
Process.Start(new ProcessStartInfo("iexplore", Link_Opel));
break;
}
}
private void comboBox3_SelectedIndexChanged(object sender, EventArgs e)
{
switch ((links_Reservedel)comboBox3.SelectedItem)
{
case links_Reservedel.Mekonomen:
Process.Start(new ProcessStartInfo("iexplore", Link_Mekonomen));
break;
case links_Reservedel.Thansen:
Process.Start(new ProcessStartInfo("iexplore", Link_Thansen));
break;
}
}
private void comboBox4_SelectedIndexChanged(object sender, EventArgs e)
{
}
}
}
And a site note, when I decompile the program, then just when I open the other frmLink form, then the first thing it do is to open those three websites.
Hope there is someone out there who can give me a point of where to go, look or maybe something else :) ..
Best regard Abrek Okur