Click here to Skip to main content
Rate this: bad
good
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">
                        <my:datagridtemplatecolumn.celltemplate>
                            <datatemplate>
                                <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>
                                    <Button Width="50" Height="30" Name="Dg_btn_Remove" Click="Dg_btn_Remove_Click">
                                        <Image Width="50" Height="26" Source="Image/delete.png" />
                                    </Button>
                                </wrappanel>
                            </datatemplate>
                        </my:datagridtemplatecolumn.celltemplate>
                    </my:datagridtemplatecolumn>
                </my:datagrid.columns>
 
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 19:49pm
Edited 9-Mar-11 20:15pm
v2
Rate this: bad
good
Please Sign up or sign in to vote.

Solution 1

You need to add four textboxes in your datatemplate.
<Stackpanel Orientation="Horizontal">
<Grid>
<TextBox Text ="{Binding Status}"/>
<TextBox Text = "{Binding Id}"/>
....
</StackPanel>
</DataTemplate>
  Permalink  
v2
Comments
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
good
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.
  Permalink  
v2

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

  Print Answers RSS
0 OriginalGriff 365
1 Sergey Alexandrovich Kryukov 319
2 CPallini 275
3 DamithSL 214
4 Maciej Los 185
0 OriginalGriff 5,455
1 DamithSL 4,457
2 Maciej Los 3,885
3 Kornfeld Eliyahu Peter 3,480
4 Sergey Alexandrovich Kryukov 3,115


Advertise | Privacy | Mobile
Web04 | 2.8.141216.1 | Last Updated 11 Mar 2011
Copyright © CodeProject, 1999-2014
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