1
有沒有在C#東西像在CSS - "float: left | right | none | inherit"
?
我想顯示在我的表格 - TextBox
及以下各TextBox
- PictureBox
。所以,我不知道每個TextBox
的大小,也可以是不同的,在我的結果覆蓋PictureBoxes
.... TextBoxes
如何在表單中放置動態項目?
static int k = 1;
for (int att = 0; att < feed.response.items[i].attachments.Count(); att++)
{
string switchCase = feed.response.items[i].attachments[att].type;
switch (switchCase)
{
case "photo":
TextBox text = new TextBox();
text.Text =Encoding.UTF8.GetString(Encoding.Default.GetBytes(feed.response.items[i].text));
Point p = new Point(20, 30 * k);
text.Location = p;
this.Controls.Add(text);
PictureBox mypic = new PictureBox();
mypic.ImageLocation = feed.response.items[i].attachments[att].photo.photo_130;
mypic.Size = new Size(100, 100);
Point g = new Point(40, 160 * k);
mypic.Location = g;
this.Controls.Add(mypic);
k++;
break;
....
}
}
嘗試使用谷歌中搜索如何將控件添加動態的形式的WinForms C# – MethodMan
我會用一個網格佈局對於這種的東西 – Gino
你可能希望['TableLayoutPanel'](https://msdn.microsoft.com/en-us/library/system.windows.forms.tablelayoutpanel(v = vs.110).aspx)與'ColumnCount'屬性設置爲「1」。如果沒有[可靠,_minimal_,_complete_代碼示例](http://stackoverflow.com/help/mcve)可以可靠地說明您的場景,那麼很難肯定地說,不必介意以代碼示例提供有用的答案。 –