|
pictureBoxを透過にして、下のコントロールを出すのは無理みたいです。
LabelのWidthを1にしてパネルとラベルに線を追加することは出来ました。
一応解決とします。
皆さんありがとうございました。
private void Form13_Load(object sender, EventArgs e) {
int line = 140;
AddLine(line);
}
private void AddLine(int position) {
for (int i = 0; i < panel1.Controls.Count; i++) {
Panel p = (Panel)panel1.Controls[i];
Label labelLine = new Label();
labelLine.Name = "labelLine";
labelLine.Location = new Point(position, 0);
labelLine.Size = new Size(1, p.Height);
labelLine.BorderStyle = BorderStyle.FixedSingle;
for (int j = 0; j < p.Controls.Count; j++) {
int startPos = p.Controls[j].Location.X;
int width = startPos + p.Controls[j].Width;
if (startPos <= position && position <= width) {
int newPosion = position - startPos;
Label labelLine2 = new Label();
labelLine2.Name = "labelLine2";
labelLine2.Location = new Point(newPosion, 0);
labelLine2.Size = new Size(1, panel2.Controls[j].Height);
labelLine2.BorderStyle = BorderStyle.FixedSingle;
p.Controls[j].Controls.Add(labelLine2);
}
}
p.Controls.Add(labelLine);
}
}
private void MoveLine(int position) {
for (int i = 0; i < panel1.Controls.Count; i++) {
Control c = panel1.Controls[i];
for (int j = 0; j < c.Controls.Count; j++) {
Control child = c.Controls[j];
if (child.Name == "labelLine") {
child.Location = new Point(position, 0);
}
child.Controls.Clear();
}
for (int j = 0; j < c.Controls.Count; j++) {
int startPos = c.Controls[j].Location.X;
int width = startPos + c.Controls[j].Width;
if (startPos <= position && position <= width) {
int newPosion = position - startPos;
Label labelLine2 = new Label();
labelLine2.Name = "labelLine2";
labelLine2.Location = new Point(newPosion, 0);
labelLine2.Size = new Size(1, panel2.Controls[j].Height);
labelLine2.BorderStyle = BorderStyle.FixedSingle;
c.Controls[j].Controls.Add(labelLine2);
}
}
}
}
private void button1_Click(object sender, EventArgs e) {
int position = 0;
string s = textBox1.Text;
if (s == "") {
position = 0;
} else {
position = int.Parse(s);
}
MoveLine(position);
}
|