I am working on a winforms app. I am experimenting with dynamic controls and have a SQL database backing the app. Here is the portion of my code that I am having a problem with:
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using System.Runtime.InteropServices;
using System.Web;
namespace Real_Estate_Manager
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}
private void button1_Click(object sender, EventArgs e)
{
btnUpdateProps.Visible = true;
}
private void Form1_Load(object sender, EventArgs e)
{
// TODO: This line of code loads data into the 'propertyManagerDataSet.Property' table. You can move, or remove it, as needed.
this.propertyTableAdapter.Fill(this.propertyManagerDataSet.Property);
}
public void btnUpdateProps_Click(object sender, EventArgs e)
{
string[] strPropTypes = new string[] { "New Build", "Renovation", "Rental" };
ComboBox ddlPurpose = new ComboBox();
ddlPurpose.Location = new Point(60, 300);
ddlPurpose.Width = 150;
ddlPurpose.Text = "Please Specify the Purpose";
ddlPurpose.Items.AddRange(strPropTypes);
this.Controls.Add(ddlPurpose);
ddlPurpose.SelectedValue = new System.EventHandler(PropType);
}
public void PropType(object sender, EventArgs e)
{
if (ddlPurpose.SelectedValue = "New Build") {
}
}
}
}
My error is in the PropType Event, in the following line of code:
if (ddlPurpose.SelectedValue = "New Build") {
The error states: "The name 'ddlPurpose' does not exist in the current context"
Basically, what I am trying to do is create an if statement or a switch statement in the PropType event. The condition statement will create more dynamic controls based on the selection of ddlPurpose.
If anyone has any suggestions for this that would be greatly appreciated.
Thank You,
roaster

New Topic/Question
Reply




MultiQuote







|