Click here to Skip to main content
15,886,689 members
Please Sign up or sign in to vote.
4.00/5 (1 vote)
See more:
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
Updated 9-Mar-11 19:15pm
v2

You need to add four textboxes in your datatemplate.
<Stackpanel Orientation="Horizontal">
<Grid>
<TextBox Text ="{Binding Status}"/>
<TextBox Text = "{Binding Id}"/>
....
</StackPanel>
</DataTemplate>
 
Share this answer
 
v2
Comments
Sagotharan Jagadeeswaran 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?.
Sagotharan Jagadeeswaran 11-Mar-11 1:19am    
i find the solution., thank u.
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.
 
Share this answer
 
v2

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



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900