回答編集履歴

1

見直しキャンペーン中

2023/07/22 07:20

投稿

TN8001
TN8001

スコア9326

test CHANGED
@@ -1,97 +1,48 @@
1
- `Grid`の`ColumnDefinition Width`のように`DataGridColumn Width`も`Auto` `Pixel`(数値)以外に、`Star` `SizeToCells`
1
+ `Grid`の`ColumnDefinition.Width`のように`DataGridColumn.Width`も`Auto``Pixel`(数値)以外に、`Star``SizeToCells`・`SizeToHeader`も指定できます。
2
-
3
- `SizeToHeader`も指定できます。
4
-
5
2
  水平スクロールバーがチラチラ出るので、消したほうがいいでしょう。
6
-
7
-
8
3
 
9
4
  [DataGrid コントロールのサイズ変更方法 # 列および列ヘッダーのサイズ変更 - WPF | Microsoft Docs ](https://docs.microsoft.com/ja-jp/dotnet/framework/wpf/controls/sizing-options-in-the-datagrid-control#sizing-columns-and-column-headers)
10
5
 
11
-
12
-
13
- ```xaml
6
+ ```xml
14
-
15
7
  <Window
16
-
17
8
  x:Class="Questions265873.MainWindow"
18
-
19
9
  xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
20
-
21
10
  xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
22
-
23
11
  xmlns:System="clr-namespace:System;assembly=mscorlib"
24
-
25
12
  Width="800"
26
-
27
13
  Height="450">
28
-
29
14
  <Grid>
30
-
31
15
  <DataGrid AutoGenerateColumns="False" ScrollViewer.HorizontalScrollBarVisibility="Disabled">
32
-
33
16
  <DataGrid.Columns>
34
-
35
17
  <DataGridTextColumn
36
-
37
18
  Width="Auto"
38
-
39
19
  Binding="{Binding}"
40
-
41
20
  Header="Auto" />
42
-
43
21
  <DataGridTextColumn
44
-
45
22
  Width="SizeToHeader"
46
-
47
23
  Binding="{Binding}"
48
-
49
24
  Header="SizeToHeader" />
50
-
51
25
  <DataGridTextColumn
52
-
53
26
  Width="SizeToCells"
54
-
55
27
  Binding="{Binding}"
56
-
57
28
  Header="SizeToCells" />
58
-
59
29
  <DataGridTextColumn
60
-
61
30
  Width="200"
62
-
63
31
  Binding="{Binding}"
64
-
65
32
  Header="Pixel200" />
66
-
67
33
  <DataGridTextColumn
68
-
69
34
  Width="*"
70
-
71
35
  Binding="{Binding}"
72
-
73
36
  Header="Star" />
74
-
75
37
  <DataGridTextColumn
76
-
77
38
  Width="2*"
78
-
79
39
  Binding="{Binding}"
80
-
81
40
  Header="2Star" />
82
-
83
41
  </DataGrid.Columns>
84
-
85
42
  <System:String>aaaa</System:String>
86
-
87
43
  <System:String>aaaaaaaaa</System:String>
88
-
89
44
  </DataGrid>
90
-
91
45
  </Grid>
92
-
93
46
  </Window>
94
-
95
47
  ```
96
-
97
48
  ![アプリ画像](88e7e7b94c90b8785923da4e0198cb5b.png)