I have WPF database application. My database has 10 tables, but one of them has a different number of columns. I edit data with TextBox
, so if I select a table with 10 columns I need to have 10 TextBoxes
.
I think I know how to add a TextBox
, but if I do it the textbox "destroys" my application. I need to repair it, change background color, color of text and margrin.
This is my code:
public void AddTb()
{
TextBox tb2 = new TextBox();
tb2.TextWrapping = TextWrapping.Wrap;
tb2.Width = 60;
tb2.Height = 23;
tb2.Margin = new Thickness(304, 50, 0, 0);
this.Content = tb2;
}
Pictures: working not working
You set the Content
of this
to the TextBox
that you are creating. You probably want to add it to some existing Panel
instead of doing this:
theNameOfThePanel.Children.Add(tb2);