Solved

WPF Datagrid column name

Posted on 2015-02-17
3
687 Views
Last Modified: 2015-02-17
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
Comment
Question by:rajeeva_nagaraj
  • 2
3 Comments
 
LVL 8

Accepted Solution

by:
Naitik Gamit earned 500 total points
ID: 40613991
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
 

Author Comment

by:rajeeva_nagaraj
ID: 40614073
Thanks for your reply. How can i access that in my code behind file.

Thanks,
Rajeeva
0
 
LVL 8

Expert Comment

by:Naitik Gamit
ID: 40614164
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

Featured Post

Master Your Team's Linux and Cloud Stack!

The average business loses $13.5M per year to ineffective training (per 1,000 employees). Keep ahead of the competition and combine in-person quality with online cost and flexibility by training with Linux Academy.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Many of us here at EE write code. Many of us write exceptional code; just as many of us write exception-prone code. As we all should know, exceptions are a mechanism for handling errors which are typically out of our control. From database errors, t…
Calculating holidays and working days is a function that is often needed yet it is not one found within the Framework. This article presents one approach to building a working-day calculator for use in .NET.
A short tutorial showing how to set up an email signature in Outlook on the Web (previously known as OWA). For free email signatures designs, visit https://www.mail-signatures.com/articles/signature-templates/?sts=6651 If you want to manage em…

839 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question