![](/img/trans.png)
[英]Using Visual Studio Windows Form Designer for other than Forms (like panels or otner)
[英]Using Visual Studio Form Like Excel
我在 Visual Studio 中創建了一個表單,但我對現在發生的事情有點迷茫。 如果我在 excel 中執行此操作,那將非常簡單,所以我想 Visual Studio 會更容易。
我想讓它填充頂部的兩個空框,具體取決於用戶單擊的按鈕。 板卡尺在第一列,順紋/逆紋在第二行和最后一列。
如果 X = Blank && Y = Blank,用文本填充 Null Box。
填寫完這些以及方向和刀片重疊后,我想將此數據作為變量發送到 CS 文件。
我想出的邏輯是::
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
為了清楚起見,我附上了一張照片並鏈接到文件https://github.com/UberGamz/FormWork
var form = new Form1();
form.ShowDialog();
這將加載表單。
var maleLandWidth = form.maleLandWidthPicked.Text;
var femaleLandWidth = form.femaleLandWidthPicked.Text;
var overlap = form.OverlapTextBox.Text;
var orientation = form.orientationSelection.Text;
如果變量設置為 Modified: Public,這將從表單中提取變量
int? mcolumn = null;
int? row = null;
int? fcolumn = null;
這需要在表單類內部,但在所有方法之外。
private void OK_click(object sender, EventArgs e)
{
this.Close();
}
當他們單擊“確定”時,這將關閉表單
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;
這將出現在你所有的按鈕上
任務完成。
謝謝大家的協助。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.