我需要在运行字符串输入的流程图时创建,我从textbox1获取。 表单大小为700 * 450,允许滚动。每个字母(来自输入字符串的字符)之间必须是(在输出中)一个箭头(显示在按钮上) * 整个图表必须在按钮* 上显示 例如,对于此输入字符串:'ABZAZAZA' 对于每个字母,都有合适的颜色,按钮的背景应该着色。
程序应该是“打印”: A - > B - > Z - > A - > Z - > A - > Z - > A - >
箭头按钮的大小:34 * 23 字母按钮的大小:34 * 29
我的代码问题,未显示流程图
下面是代码:
public void DrawingSystem(string st)
{
shura_acid = 12;
tur_acid = 185;
for (int i = 1; i <= st.Length; i++)
{
if ((i % 7) == 0)
{
OpenNewLine();
}
CreateAcid(st[i - 1], i);
shura_acid = shura_acid + 24 + 68;
}
}
public void OpenNewLine()
{
tur_acid = tur_acid + 29 + 12;//34 because the size of button,12 because space between lines
shura_acid = 12;
}
public void CreateAcid(char letter, int i)
{
//create acid
Button acid = new Button();
acid.Location = new System.Drawing.Point(shura_acid, tur_acid);
acid.Name = "acid" + i;
acid.Size = new System.Drawing.Size(34, 29);
acid.TabIndex = 100 + i;
acid.Text = Convert.ToString(letter);
switch (letter)
{
case 'A': acid.BackColor = System.Drawing.Color.Fuchsia; break;
case 'C': acid.BackColor = System.Drawing.Color.Pink; break;
case 'D': acid.BackColor = System.Drawing.Color.Gray; break;
case 'F': acid.BackColor = System.Drawing.Color.Azure; break;
case 'G': acid.BackColor = System.Drawing.Color.Red; break;
case 'H': acid.BackColor = System.Drawing.Color.Aqua; break;
case 'I': acid.BackColor = System.Drawing.Color.Lime; break;
case 'K': acid.BackColor = System.Drawing.Color.Yellow; break;
case 'L': acid.BackColor = System.Drawing.Color.Olive; break;
case 'M': acid.BackColor = System.Drawing.Color.Coral; break;
case 'N': acid.BackColor = System.Drawing.Color.SaddleBrown; break;
case 'P': acid.BackColor = System.Drawing.Color.Teal; break;
case 'Q': acid.BackColor = System.Drawing.Color.Blue; break;
case 'R': acid.BackColor = System.Drawing.Color.Orange; break;
case 'S': acid.BackColor = System.Drawing.Color.Green; break;
case 'T': acid.BackColor = System.Drawing.Color.SteelBlue; break;
case 'V': acid.BackColor = System.Drawing.Color.DarkViolet; break;
case 'W': acid.BackColor = System.Drawing.Color.Crimson; break;
case 'X': acid.BackColor = System.Drawing.Color.MediumAquamarine; break;
default: acid.BackColor = System.Drawing.Color.Gold; break;
}
//create arrow
Button arrow = new System.Windows.Forms.Button();
arrow.Location = new System.Drawing.Point(shura_acid + 34 + 12, tur_acid);
arrow.Name = "acid" + i;
arrow.Size = new System.Drawing.Size(34, 23);
arrow.TabIndex = 100 + i;
arrow.Text = "-->";
arrow.UseVisualStyleBackColor = false;
}
答案 0 :(得分:1)
我会捅它。我的代码中没有,我发现您实际上已将acid
或arrow
按钮添加到容器中。
你需要这样的东西:
this.Controls.Add(acid);
和
this.Controls.Add(arrow);
将this.Controls
更改为您希望它们出现的容器。