Click here to Skip to main content
15,887,585 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
I am currently add datagrid column automatically

Such as:
C#
dgForData.Columns.Add(new System.Windows.Controls.DataGridTextColumn() { Header = getData.DataPrice, Binding = new System.Windows.Data.Binding(getData.DataFiledPrice) });
         dgForData.Columns.Add(new System.Windows.Controls.DataGridCheckBoxColumn() { Header = getData.DataIsCabinetContains, Width = DataGridLength.Auto, Binding = new System.Windows.Data.Binding(getData.DataFiledIsCabinetContains) });


I want to add a checkBox in the column next to the title, and you can use it to achieve the click event Select function, but I do not know how to add.

[edit]Code block corrected[/edit]

In front of the wrong word, I asked the title plus checkBox


such as
XML
<DataGridTemplateColumn Width="0.3*">
                                    <DataGridTemplateColumn.Header>
                                        <CheckBox  x:Name="CbTeacherDevice" Content="序号">
                                        </CheckBox>
                                    </DataGridTemplateColumn.Header>
                                    <DataGridTemplateColumn.CellTemplate>
                                        <DataTemplate>
                                            <CheckBox Margin="12,0,0,0"></CheckBox>
                                        </DataTemplate>
                                    </DataGridTemplateColumn.CellTemplate>
                                </DataGridTemplateColumn>


Just about the form, but I want to add this column is dynamic
Posted
Updated 2-Jan-14 23:21pm
v4
Comments
Naz_Firdouse 3-Jan-14 5:24am    
what is the issue you are facing?

1 solution

 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900