WPF Thickness (Margin)

索引サイト表示
画面標準設定 (Grid)




public partial class MainWindow : Window
{
public MainWindow()
{
InitializeComponent();
}

private TextBox[] textCode01 = new TextBox[10];
private TextBox[] textCode02 = new TextBox[10];
private TextBox[] textCode03 = new TextBox[10];
private TextBox[] textName01 = new TextBox[10];

private void button0_Click(object sender, RoutedEventArgs e)
{
for (int idx = 1; idx < 10; idx++)
{
textCode01[idx] = new TextBox();
textCode02[idx] = new TextBox();
textCode03[idx] = new TextBox();
textName01[idx] = new TextBox();

textCode01[idx].Name = "textCode01" + idx.ToString("00");
textCode02[idx].Name = "textCode02" + idx.ToString("00");
textCode03[idx].Name = "textCode03" + idx.ToString("00");
textName01[idx].Name = "textNode01" + idx.ToString("00");

textCode01[idx].SetValue(Grid.MarginProperty, new Thickness(2));
textCode02[idx].SetValue(Grid.MarginProperty, new Thickness(2));
textCode03[idx].SetValue(Grid.MarginProperty, new Thickness(2));
textName01[idx].SetValue(Grid.MarginProperty, new Thickness(2));

textCode01[idx].SetValue(Grid.ColumnProperty, 1);
textCode02[idx].SetValue(Grid.ColumnProperty, 2);
textCode03[idx].SetValue(Grid.ColumnProperty, 3);
textName01[idx].SetValue(Grid.ColumnProperty, 4);

textCode01[idx].SetValue(Grid.RowProperty, idx);
textCode02[idx].SetValue(Grid.RowProperty, idx);
textCode03[idx].SetValue(Grid.RowProperty, idx);
textName01[idx].SetValue(Grid.RowProperty, idx);

textCode01[idx].Background = Brushes.AliceBlue;
textCode02[idx].Background = Brushes.AntiqueWhite;
textCode03[idx].Background = Brushes.Aqua;
textName01[idx].Background = Brushes.Aquamarine;

grid1.Children.Add(textCode01[idx]);
grid1.Children.Add(textCode02[idx]);
grid1.Children.Add(textCode03[idx]);
grid1.Children.Add(textName01[idx]);
}
}

private void button1_Click(object sender, RoutedEventArgs e)
{
Button wButton = (Button)e.Source;
int idx = Convert.ToInt16(wButton.Tag);
textCode01[idx].Focus();
}
}



AX