7
可能重複:
It is possible to copy all the properties of a certain control? (C# window forms)克隆控制 - C#(WinForm的)
我要創建一個類似的設計時創建一個控制一些控件。創建的控件應該與預定義的控件具有相同的屬性,換句話說,我想複製一個控件。有沒有用於此目的的單行代碼?或者我必須通過一行代碼來設置每個屬性? 我現在正在做正確的是:
ListContainer_Category3 = new FlowLayoutPanel();
ListContainer_Category3.Location = ListContainer_Category1.Location;
ListContainer_Category3.BackColor = ListContainer_Category1.BackColor;
ListContainer_Category3.Size = ListContainer_Category1.Size;
ListContainer_Category3.AutoScroll = ListContainer_Category1.AutoScroll;