WPF Datagrid column name

Posted on 2015-02-17
Medium Priority
Last Modified: 2015-02-17

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,
Question by:rajeeva_nagaraj
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2

Accepted Solution

Naitik Gamit earned 2000 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">
                                        <TextBlock  Text="{Binding CURRENT_STAGE}" Style="{StaticResource Style_TextBlock_DGCell}" Name="Txt_Stage"/>

Author Comment

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


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;

Featured Post

Want to be a Web Developer? Get Certified Today!

Enroll in the Certified Web Development Professional course package to learn HTML, Javascript, and PHP. Build a solid foundation to work toward your dream job!

Question has a verified solution.

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

Wouldn’t it be nice if you could test whether an element is contained in an array by using a Contains method just like the one available on List objects? Wouldn’t it be good if you could write code like this? (CODE) In .NET 3.5, this is possible…
Real-time is more about the business, not the technology. In day-to-day life, to make real-time decisions like buying or investing, business needs the latest information(e.g. Gold Rate/Stock Rate). Unlike traditional days, you need not wait for a fe…
Monitoring a network: how to monitor network services and why? Michael Kulchisky, MCSE, MCSA, MCP, VTSP, VSP, CCSP outlines the philosophy behind service monitoring and why a handshake validation is critical in network monitoring. Software utilized …
Visualize your data even better in Access queries. Given a date and a value, this lesson shows how to compare that value with the previous value, calculate the difference, and display a circle if the value is the same, an up triangle if it increased…
Suggested Courses

800 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