How to dynamically add controls to your user interface in c#.net |
|||
CONTROLS C# DYNAMICALLYC# Tutorials |
|||
|
|
|||
|
|
|||
CONTROLS C SHARP DYNAMICALLYLearn Tutorials |
|
How to dynamically add controls to your user interface in c#.net
Example code for Controls c sharp dynamically: public void AddControls(Form theForm) { Hashtable textBoxHT=new Hashtable(); int yPos=10; theForm.SuspendLayout(); foreach(string stringInArray in controlItemsList) { //Console.WriteLine("added "+stringInArray); Label tempLabel=new Label(); tempLabel.Width=138; tempLabel.TextAlign=ContentAlignment.MiddleRight; tempLabel.Text=stringInArray+":"; tempLabel.Location=new System.Drawing.Point(10, yPos); TextBox tempShortText=new TextBox(); tempShortText.Location=new System.Drawing.Point(150, yPos); tempShortText.Width=100; //tempShortText.Text=stringInArray;//get this from the XML TextBox tempLongText=new TextBox(); tempLongText.Location=new System.Drawing.Point(270, yPos); tempLongText.Width=250; //tempLongText.Text=stringInArray;//get this from the XML theForm.Controls.Add(tempShortText); theForm.Controls.Add(tempLongText); theForm.Controls.Add(tempLabel); yPos+=22; } theForm.ResumeLayout(); } |
Home
CSHARP Arrays in c sharp C sharp array objects C sharp separators context menu Compare dates csharp datetime Context menu c sharp Context menus csharp example Controls c sharp dynamically Database access c sharp Database access with ADO NET DataGrid c sharp Datagrid dataset csharp NET Datagrid Styles data grid Datasets listview dropdown selectbox Dialogbox csharp dialog box Drag and drop csharp Listview combo box csharp Looping through hashtable NET NET collections tutorial NET crawler safe url One row from dataset Output datetime csharp Popup form csharp Try catch c sharp |
||||||
![]() | |||||||