简体   繁体   English

像 Excel 一样使用 Visual Studio 窗体

[英]Using Visual Studio Form Like Excel

I have created a Form in Visual Studio, but I'm a little lost on what happens now.我在 Visual Studio 中创建了一个表单,但我对现在发生的事情有点迷茫。 If I was doing this in excel, it'd be pretty simple so I'd imagine Visual Studio is even easier.如果我在 excel 中执行此操作,那将非常简单,所以我想 Visual Studio 会更容易。

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.如果 X = Blank && Y = Blank,用文本填充 Null Box。

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.填写完这些以及方向和刀片重叠后,我想将此数据作为变量发送到 CS 文件。

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 https://github.com/UberGamz/FormWork为了清楚起见,我附上了一张照片并链接到文件https://github.com/UberGamz/FormWork 在此处输入图像描述

        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如果变量设置为 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.谢谢大家的协助。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM