How do you code a Combo Box (Drop down link box) with a submit button in windows form application in C#, in visual studios 2013.
This is what I want exactly but in c# - http://www.itechies.net/tutorials/jscript/jsexample.php-pid-combo.htm
I have to save space on my application, this would be the best route.
After selecting from the list box, click on the button and it would load a new webpage with the item selected.
Edit:
This is the code now, and Its still not working. Getting errors with "(this.DropDownList1.SelectedValue) " dropdownList1 getting errors.
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
namespace WindowsFormsApplication1
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}
protected override void WndProc(ref Message m)
{
base.WndProc(ref m);
if (m.Msg == WM_NCHITTEST)
m.Result = (IntPtr)(HT_CAPTION);
}
private const int WM_NCHITTEST = 0x84;
private const int HT_CLIENT = 0x1;
private const int HT_CAPTION = 0x2;
private void Form1_Load(object sender, EventArgs e)
{
}
private void button1_Click(object sender, EventArgs e)
{
{
switch (this.DropDownList1.SelectedValue)
{
case "Google":
this.Response.Redirect("http://www.google.com");
break;
case "Yahoo":
this.Response.Redirect("http://www.yahoo.com");
break;
case "Codeproject":
this.Response.Redirect("http://www.codeproject.com");
break;
}
}
}
private void comboBox1_SelectedIndexChanged(object sender, EventArgs e)
{
}
}
}
Edit:
I'm very confused with this, I tried this but no success...I know its totally wrong, does anyone know how to solve this. I have a combobox1 that has three websites in it, and I have a button that submits what you pick in the combobox1, in c# not any other language please. Thanks in advance if you know how to solve this.
private void button1_Click(object sender, EventArgs e)
{
{
switch (this.comboBox1.Text)
{
case "Google":
this.comboBox1("http://www.google.com");
break;
case "Yahoo":
this.comboBox1("http://www.yahoo.com");
break;
case "Codeproject":
this.comboBox1("http://www.codeproject.com");
break;
}
}
}