Click here to Skip to main content
15,901,505 members
Home / Discussions / C#
   

C#

 
GeneralRe: SQL.. please help.. Pin
Christian Graus28-Jun-05 18:04
protectorChristian Graus28-Jun-05 18:04 
GeneralRe: SQL.. please help.. Pin
fire8528-Jun-05 18:09
fire8528-Jun-05 18:09 
GeneralRe: SQL.. please help.. Pin
Christian Graus28-Jun-05 18:11
protectorChristian Graus28-Jun-05 18:11 
GeneralRe: SQL.. please help.. Pin
fire8528-Jun-05 18:20
fire8528-Jun-05 18:20 
GeneralRe: SQL.. please help.. Pin
Christian Graus28-Jun-05 18:28
protectorChristian Graus28-Jun-05 18:28 
GeneralRe: SQL.. please help.. Pin
fire8528-Jun-05 18:50
fire8528-Jun-05 18:50 
Questionuser control Collection Editor ? Pin
CiNN28-Jun-05 13:07
CiNN28-Jun-05 13:07 
AnswerRe: user control Collection Editor ? Pin
Christian Graus28-Jun-05 13:36
protectorChristian Graus28-Jun-05 13:36 
GeneralRe: user control Collection Editor ? Pin
CiNN28-Jun-05 21:17
CiNN28-Jun-05 21:17 
GeneralRe: user control Collection Editor ? Pin
Christian Graus29-Jun-05 11:25
protectorChristian Graus29-Jun-05 11:25 
Generalwaitforexit doesn't wait Pin
thepersonof28-Jun-05 7:58
thepersonof28-Jun-05 7:58 
GeneralRe: waitforexit doesn't wait Pin
Nick Parker28-Jun-05 9:51
protectorNick Parker28-Jun-05 9:51 
GeneralRe: waitforexit doesn't wait Pin
thepersonof28-Jun-05 10:04
thepersonof28-Jun-05 10:04 
GeneralRe: waitforexit doesn't wait Pin
Dave Kreskowiak28-Jun-05 15:41
mveDave Kreskowiak28-Jun-05 15:41 
GeneralRe: waitforexit doesn't wait Pin
thepersonof29-Jun-05 8:06
thepersonof29-Jun-05 8:06 
GeneralEasy Forms Question Pin
mikemmmmmm28-Jun-05 6:39
mikemmmmmm28-Jun-05 6:39 
GeneralRe: Easy Forms Question Pin
Anonymous28-Jun-05 6:54
Anonymous28-Jun-05 6:54 
GeneralRe: Easy Forms Question Pin
Matt Gerrans28-Jun-05 9:07
Matt Gerrans28-Jun-05 9:07 
GeneralRe: Easy Forms Question Pin
mikemmmmmm28-Jun-05 11:41
mikemmmmmm28-Jun-05 11:41 
GeneralRe: Easy Forms Question Pin
Matt Gerrans28-Jun-05 14:20
Matt Gerrans28-Jun-05 14:20 
Here's a minimal example, without validation, etc.

Snippet from the main form (extraneous stuff omitted):

class MainForm : Form
{
    private string chosenPizza = "Pepperoni";
    private bool cheesy = true;

    private void buttonChooseNewPizza_Click(object sender, EventArgs e)
    {
        PizzaOrderForm orderForm = new PizzaOrderForm();
        orderForm.PizzaType = chosenPizza;
        orderForm.Cheesy = cheesy;
        DialogResult answer = orderForm.ShowDialog(this);
        if (answer == DialogResult.OK)
        {
            chosenPizza = orderForm.PizzaType;
            cheesy = orderForm.Cheesy;
            labelOrderStatus.Text = "Your " + chosenPizza + " pizza with" +
                                    (cheesy ? "" : "out") + 
                                    " cheese is coming right up!";
        }
    }
}


And from the sub-dialog form:
partial class PizzaOrderForm : Form
{
  public PizzaOrderForm()
  {
     InitializeComponent();
  }

  private string pizzaType;
  public string PizzaType
  {
     get
     {
        return pizzaType;
     }
     set
     {
        switch (value.ToLower())
        {
           case "pepperoni":
           case "hawaiian":
           case "vegetarian":
              pizzaType = value;
              break;
           default:
              throw new ArgumentOutOfRangeException(string.Format("Sorry, {0} pizza is not on the menu.", value ));
        }
     }
  }
  private bool cheesy = true;
  public bool Cheesy
  {
     get
     {
        return cheesy;
     }
     set
     {
        cheesy = value;
     }
  }

  private void PizzaOrderForm_Load(object sender, EventArgs e)
  {
     textBoxPizza.Text = PizzaType;
     checkBoxCheese.Checked = Cheesy;
  }

  private void buttonOK_Click(object sender, EventArgs e)
  {
     PizzaType = textBoxPizza.Text;
     Cheesy = checkBoxCheese.Checked;
  }
}

Also, the OK and Cancel button's DialogResult properties should be set accordingly.

(If you're using .NET 1.0 or before, don't be confounded by the partial class, it just lets the form designer do all its code generation in a separate file).

Matt Gerrans
GeneralRe: Easy Forms Question Pin
Anonymous28-Jun-05 20:12
Anonymous28-Jun-05 20:12 
GeneralRe: Easy Forms Question Pin
Matt Gerrans29-Jun-05 5:30
Matt Gerrans29-Jun-05 5:30 
GeneralSetup File Pin
Yigal Agam28-Jun-05 6:30
Yigal Agam28-Jun-05 6:30 
GeneralRe: Setup File Pin
Nick Parker28-Jun-05 9:54
protectorNick Parker28-Jun-05 9:54 
GeneralRe: Setup File Pin
Yigal Agam28-Jun-05 10:02
Yigal Agam28-Jun-05 10:02 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.