Improve company productivity with a Business Account.Sign Up

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 1358
  • Last Modified:

WPF Datagrid column name

Hi,

How do i set a column name for a datagrid column in wpf. it will be very helpful if you can send me an example code.

Thanks in advance,
Rajeeva
0
rajeeva_nagaraj
Asked:
rajeeva_nagaraj
  • 2
1 Solution
 
Naitik GamitSoftware DeveloperCommented:
Try As Belove:
you can give column name in wpf as: x:Name="Your Column Name".


   <sdk:DataGridTemplateColumn Header="Current Stage" x:Name="Col_Current_Stage" HeaderStyle="{StaticResource dgcolheaderStyle}" Width="150">
                                <sdk:DataGridTemplateColumn.CellTemplate>
                                    <DataTemplate>
                                        <TextBlock  Text="{Binding CURRENT_STAGE}" Style="{StaticResource Style_TextBlock_DGCell}" Name="Txt_Stage"/>
                                    </DataTemplate>
                                </sdk:DataGridTemplateColumn.CellTemplate>
                            </sdk:DataGridTemplateColumn>
0
 
rajeeva_nagarajAuthor Commented:
Thanks for your reply. How can i access that in my code behind file.

Thanks,
Rajeeva
0
 
Naitik GamitSoftware DeveloperCommented:
in code behind you can access column as per your requirement.
for example::i want to visible column for only one department then the code behind as,

private void DataGridColumn_Visibility_Setting()
        {
            foreach (var item in dg_Inward.Columns)
           {
                switch (item.GetValue(NameProperty).ToString().ToUpper())
               {
                               case "COL_FILE_NO":           //Column Nmae
                               case "COL_QUERY_DATE":   //Column Name
                               item.IsVisible = GlobalClass.G_CurrentRole.IS_ADMIN_ROLE == true;
                               break;
                               default:
                               break;
                      }
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

Join & Write a Comment

Featured Post

Free Tool: Site Down Detector

Helpful to verify reports of your own downtime, or to double check a downed website you are trying to access.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now