Making an advanced settings form

I am working on a user interface that needs to have a form added for advanced settings for the program. I have added a button and set the event handler for the button to call up the new form, but I am unable to get the program to take any of the settings from the advanced form. Everything is under the same namespace, but it will not find them, so when I try to build my program I get an error for each time that one of the settings from the advanced tab is called out. Is there a call out that I am forgetting, or do I need to change each callout to reflect that the setting is on a different form
Thanks
SVandal


Answer this question

Making an advanced settings form

  • Okugops

    Yes, the AdvancedForm has the x_counts numericU/D control on the AdvancedForm.cs (design). I went into AdvancedForm.cs and typed in x_counts. and intellisense detects it. If I do it on the main Carriage_Motion_Controller.cs form intellisense does not detect it.

    In the AdvancedForm.cs (design) x_counts is the numericU/D on the form, otherwise it is not in the AdvancedForm.cs code.

    Is there a way to assign the x,y,z_counts and x,y,z_counts to a method so that it will reference them from the main Form

    Also, when using the NumericUpDown.Value, what is a returned, an interger, bool, dec..
    Thanks,
    SVandal

  • ChrisCurry

    can you post some code please, this will help us alot

  • David465465454

    hmm, from the code you posted it seems as if this AdvancedForms does have the x_counts control, correct

    If you do, on this form, x_count and place a period (dot) - does intellisense detect it

    of course its a compile time issue. Where is x_count in this advanced form Does it exist at all Or are you trying to refer x_count on the previous form



  • Mastroyani

    Also, the error says that "the name xxxxxx does not exist in the current context".
    Thanks

  • dto

    My program consists of a main form named Carriage_Motion_Controller

    public partial class Carriage_Motion_Controller : Form


    Essentially I have 6 numericUpDowns on a different form

    public partial class AdvancedForm : Form

    The updowns are named:
    x_counts
    y_counts
    z_counts
    x_travel
    y_travel
    z_travel

    In the main form (CMC) the values of the numericUp/Downs is called for for different equations. As shown below.

    locx.Text = "" + Math.Round(x_axis.Current / x_counts.Value);
    locy.Text = "" + Math.Round(y_axis.Current / y_counts.Value);
    locz.Text = "" + Math.Round(z_axis.Current / z_counts.Value);

    locx, y, z are labels that display the current position, and x,y,z_axis is a seperate class that has been created called axis that allows for different values to be called out.

    The event handler for the button (named advanced) that opens the AdvancedForm so that the advanced settings can be changed is

    private void advanced_click(object sender, Eventarg e)
    {
    Form AdvancedForm = new AdvancedForm();
    AdvancedForm.show();
    }

    Under the AdvancedForm.cs I have only added in a closing event with a yes/no confirmation as per the example on page 366 of Microsft Visual C# 2005 step by step.
    Let me know if this helps to clarify it, or if I need to include something else.
    Thanks,
    SVandal

  • dslarve

    On the error list it cites every instance of the occurance of x_counts, y_counts, z_counts, x_travel, y_travel, z_travel and says that "The name x_counts does not exist in the current context".


  • Joannes Vermorel - MSP

    Glad I could be of assistance! :-)

  • RedMage44x

    sorry, are you also able to post the error message you are getting and the line of code it is point to

  • Hans Preuer

    the NumericUpDown.Value returns a value of decimal.

    If you need to pass values from one form to another, you are best exposing a method publically in your "child" form, and calling it from the main forum. Example:



    //Main Form
    ..
    ..
    TheChildForm theChildForm = new TheChildForm();
    theChildForm.SomeMethod(this.theNumericUpDown.Value, param2, param3.....);
    theChildForm.Show();



    '"Child" form:
    public void SomeMethod(decimal number, type param2, type param3.....)
    {
    //do stuff with parameters
    }

    this is just an example.

    You can also pass a reference of the calling form to the child form, but sometimes this can be bad practice as you do not wish to expose methods to another form and messing up the form, so its best to just pass the appropriate things you want to pass to the calling form (child form) via properties or methods.

    But if you must (again bad practice)



    'Child form:

    public TheMainForm theMainForm = null;
    ..
    ..
    //Constructor of this ChildForm:
    public ChildForm(TheMainForm mainForm)
    {
    this.theMainForm = mainForm;
    ...
    }

    //Main Form:

    ..
    ChildForm theChildForm = new ChildForm(this);
    theChildForm.Show();

    does this help



  • KAAU

    Thanks for the help, now I am that much closer to being completed.

  • Making an advanced settings form