Home > Blockchain >  Using Visual Studio Form Like Excel
Using Visual Studio Form Like Excel

Time:12-25

I have created a Form in Visual Studio, but I'm a little lost on what happens now. If I was doing this in excel, it'd be pretty simple so I'd imagine Visual Studio is even easier.

I'm looking to have it fill in the two null boxes at the top, dependent on what buttons the user has clicked. Board Caliper being in the First Column and the With Grain / Against Grain being in the second row and the last columns.

If X = Blank && Y = Blank, fill in Null Box with text.

Once those are filled in, along with the orientation and blade overlap, I'd like to send this data to the CS file as variables.

The logic I've come up with is ::

Board Caliper Buttons
    Show clicked when clicked
    If a different one is clicked, remove 'clicked' indicator of other

With Grain / Against Grain button
    Show clicked when clicked
    If a different one is clicked, remove 'clicked' indicator of other

Male Land Width = null
    When both Board Caliper and With Grain/ Against Grain buttons are clicked, find intersection box in table and load that text value into the Null box

Okay Button
    When Male Land Width/ Female Land is not null, orientation is selected, blade overlap is not null
        Send four values to CS file

I've attached a photo for clarity and linked to the files enter image description here

CodePudding user response:

        var form = new Form1();
        form.ShowDialog();

This will load the form.

        var maleLandWidth = form.maleLandWidthPicked.Text;
        var femaleLandWidth = form.femaleLandWidthPicked.Text;
        var overlap = form.OverlapTextBox.Text;
        var orientation = form.orientationSelection.Text;

This will pull the variables from the form if they are set to Modified : Public

    int? mcolumn = null;
    int? row = null;
    int? fcolumn = null;

This needs to be inside the form class, but outside of all the methods.

    private void OK_click(object sender, EventArgs e)
    {
        this.Close();
    }

This will close the form when they click 'OK'

            for (int i = 2; i < tableLayoutPanel1.RowCount; i  )
            {
                for (int j = 1; j < tableLayoutPanel1.ColumnCount; j  )
                {
                    tableLayoutPanel1.GetControlFromPosition(j, i).BackColor = Color.Gainsboro;
                }
            }
            var tempControl = tableLayoutPanel1.GetControlFromPosition((int)mcolumn, (int)row).Text;
            tableLayoutPanel1.GetControlFromPosition((int)mcolumn, (int)row).BackColor = Color.Teal;
            maleLandWidthPicked.Text = tempControl;
            var ftempControl = tableLayoutPanel1.GetControlFromPosition((int)fcolumn, (int)row).Text;
            tableLayoutPanel1.GetControlFromPosition((int)fcolumn, (int)row).BackColor = Color.Teal;
            femaleLandWidthPicked.Text = ftempControl;

This will go on all of your buttons

Mission Complete.

Thank you everyone for the assist.

  • Related