2014-09-05 54 views
-1

如何在c#中獲取TableLayoutPanel右側的圖片框圖像?目前我正在標籤圖像下一行,但我需要一個標籤旁邊的圖片框的文本在TableLayoutPanel。這裏是我的代碼如何保留圖片框右側的表格以窗口形式佈局c#

PictureBox pb = new PictureBox(); 
pb.ImageLocation = ../imagesDT/answered.gif 
tableLayoutPanel1.Controls.Add(pb); 

我想保持標籤旁邊的圖像中TableLayoutPanel,但目前獲得的圖像在標籤下方。

回答

0

試試這個:

class Form4 : Form { 

    PictureBox pb = new PictureBox() { BackColor = Color.RosyBrown, Dock = DockStyle.Fill }; 
    Label lb = new Label { Text = "Label", AutoSize = true }; 
    TableLayoutPanel panel = new TableLayoutPanel { Dock = DockStyle.Fill }; 
    public Form4() { 
     Controls.Add(panel); 
     panel.Controls.Add(lb, 0, 0); 
     panel.Controls.Add(pb, 1, 0); 
    } 
} 
相關問題