chalupabatman
Member
- Joined
- Nov 6, 2014
- Messages
- 8
- Programming Experience
- Beginner
I am dynamically creating text boxes & labels based off of data being pulled from a table. Sometimes the field will have 2 possible answers, so I need each answer to be on the same line as the field
I was attempting to use the rowindex but I still can't get the syntax down so that it displays as I need, like the example above. This is the model, I am working with
EDIT -- I guess a better way of looking at what I want to accomplish is the column/row location on the TLP of where I want to add my data. This is how I want to add my information
C#:
field ---- answer
EmpID ID
Phone Phone1 Phone2
Address Address
I was attempting to use the rowindex but I still can't get the syntax down so that it displays as I need, like the example above. This is the model, I am working with
C#:
int rowinde = 0;
foreach (string label in c.LabelsNeeded)
{
//Adding in a label
Label lbl = new Label();
lbl.Name = "lbl_" + index;
lbl.Text = label;
lbl.AutoSize = true;
tableLayoutPanel1.Controls.Add(lbl);
//Adding in a textbox
TextBox tbx = new TextBox();
tbx.Name = "txt_" + index;
tbx.AutoSize = true;
//Only increment the index if the label is not null
//meaning there was a new label added
if (string.IsNullOrEmpty(lbl.Text) != true) { tableLayoutPanel1.Controls.Add(tbx); }
else { tableLayoutPanel1.Controls.Add(tbx, rowindex++) }
index++
}
EDIT -- I guess a better way of looking at what I want to accomplish is the column/row location on the TLP of where I want to add my data. This is how I want to add my information
C#:
EmpID - add at - column1, row1 -----ID - add at - column2, row1
Phone - add at - column1, row2 -----Phone1 - add at - column2, row2 --- Phone2 - add at - column2, row 2 (Phone2 should be added at the same row, but moved slightly over not on top of Phone1)
Address - add at - column1, row3 ---- Address - add at - column2, row3
Last edited: