在FlowLayoutPanel中处理动态添加的控件

时间:2015-01-30 20:10:46

标签: c# dynamic size controls flowlayoutpanel

我正在尝试创建一个可选择的滚轮,其中FlowLayoutPanel中所选的子对象的大小会增加。

如何在动态创建对象后增加FlowLayoutPanel内对象的大小?

class CustomFlowLayout : FlowLayoutPanel
{

    public List<Node> ChildList = new List<Node>();
    Node SelectedNode = new Node();

    public CustomFlowLayout(){ }

    //
    //Methods
    //
    public void DrawList()
    { 
        if (this.ChildList.Count == 0)
        {
            MessageBox.Show("No Systems found");                
        }
        else
        {
            SelectedNode = ChildList[0];
            for (int i = 0; i < ChildList.Count; i++)
            {
                PictureBox CurrentPic = new PictureBox();
                CurrentPic.Name = ChildList[i].Name;
                CurrentPic.Width = 400;
                CurrentPic.Height = 200;            
                CurrentPic.Image = ChildList[i].NodePicture;
                this.Controls.Add(CurrentPic);
            }                                                                      
        }//end else
    }//end DrawList()
}//end Class

节点类

namespace Nostalgia{
class Node 
{
    public bool isSelected = false;
    public string Name;
    public Bitmap NodePicture;
    public int ListPosition;
    //
    //Constructors
    //
    public Node() { }
}

0 个答案:

没有答案