This is a follow up question for my previous question.
However in this question, I created such a Control so whenever I click on the button, two TextBoxes will appear (Indefinite count/click) in a row. Whenever I input again a value, they will do the addition and put the result in the third TextBox of their row.
private void buttonNewRow_Click(object sender, EventArgs e)
{
int count = 1;
DateTimePicker date = new DateTimePicker();
count = panel1.Controls.OfType<DateTimePicker>().ToList().Count;
date.Location = new Point(0, 15 * count);
date.Size = new Size(91, 20);
panel1.Controls.Add(date);
//Textbox 1
TextBox textboxTranspo = new TextBox();
textboxTranspo.Location = new Point(576, 45 * count);
textboxTranspo.Size = new Size(81, 20);
panel1.Controls.Add(textboxTranspo);
//Textbox 2
TextBox textboxDaily = new TextBox();
textboxDaily.Location = new Point(663, 45 * count);
textboxDaily.Size = new Size(81, 20);
panel1.Controls.Add(textboxDaily);
//Textbox 1 + Textbox 2 result
TextBox textboxTotal = new TextBox();
textboxTotal.Location = new Point(772, 45 * count);
textboxTotal.Size = new Size(100, 20);
panel1.Controls.Add(textboxTotal);
}
How can I accomplish this?
UserControl. You can add your logic to the user control and you just add it to the your panel programmatically.FlowLayoutPanelorDataGridViewcontrols instead ofPanelcan make it a bit easier.