Click here to Skip to main content
11,805,035 members (60,873 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" />

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 315
1 Richard Deeming 200
2 Sergey Alexandrovich Kryukov 168
3 CPallini 160
4 CHill60 150
0 OriginalGriff 3,255
1 Maciej Los 1,990
2 KrunalRohit 1,907
3 CPallini 1,855
4 Richard MacCutchan 1,227

Advertise | Privacy | Mobile
Web02 | 2.8.151002.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