Click here to Skip to main content
11,634,631 members (66,694 online)
Rate this: bad
Please Sign up or sign in to vote.
See more: C# WPF
hi friends,

in my program datagrid, i add a template column

xmal -
                <my:datagrid.columns xmlns:my="#unknown">
                    <my:datagridtemplatecolumn header="Status" width="110">
                                <wrappanel name="DG_warpPanel">
                                    <Button Width="50" Height="30" Name="DG_btn_Upload" Click="DG_btn_Upload_Click">
                                        <Image Width="50" Height="26" Source="Image/Tick.png" />
                                    <Button Width="50" Height="30" Name="Dg_btn_Remove" Click="Dg_btn_Remove_Click">
                                        <Image Width="50" Height="26" Source="Image/delete.png" />

c# code -
 dataGrid1.DataContext = from re in MainWindow.mcsEntity.mcs_image
                              where re.mcs_Image_Code == txt_Code.Text
                              select new
                                  Id = re.mcs_Image_Id,
                                  Image = re.mcs_Image_Image,
                                  Location = re.mcs_Image_LocationMap

now it give the output

Status | Id | Image | Location.

but i want Id | Image | Location | Status

I saw one propriety Display Index,. how to set this,.

so give me any idea,.
Posted 9-Mar-11 18:49pm
Edited 9-Mar-11 19:15pm
Rate this: bad
Please Sign up or sign in to vote.

Solution 1

You need to add four textboxes in your datatemplate.
<Stackpanel Orientation="Horizontal">
<TextBox Text ="{Binding Status}"/>
<TextBox Text = "{Binding Id}"/>
jagadees1808 at 10-Mar-11 3:29am
i try that,. but i cant get the row value,. so only i switch to old code.

do you know how set the display index?.
jagadees1808 at 11-Mar-11 1:19am
i find the solution., thank u.
Rate this: bad
Please Sign up or sign in to vote.

Solution 2

I try to get help for my problem. but wpf experts not give me the solution.(All are so busy?).

I try and find the solution. i hope this code help who have the same problem in wpf datagrid.

 if (columnCount == 4)
     dataGrid1.Columns[0].DisplayIndex = 3;
     dataGrid1.Columns[1].DisplayIndex = 0;
     dataGrid1.Columns[2].DisplayIndex = 1;
     dataGrid1.Columns[3].DisplayIndex = 2;

thank u very much.

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

  Print Answers RSS
0 OriginalGriff 8,736
1 Sergey Alexandrovich Kryukov 8,419
2 Mika Wendelius 6,845
3 F-ES Sitecore 2,354
4 Suvendu Shekhar Giri 2,205

Advertise | Privacy | Mobile
Web04 | 2.8.150728.1 | Last Updated 11 Mar 2011
Copyright © CodeProject, 1999-2015
All Rights Reserved. Terms of Service
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100