本文介绍了如何在WPF DataGrid模板列中设置显示列索引?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
朋友,
在我的程序datagrid中,我添加了一个模板列
xmal-
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#代码-
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
};
现在它给出了输出
现状ID |图片|位置.
但我要身份证|图片|位置|状态
我看到了一个适当的展示索引.如何设置这个.
因此,请给我任何想法.
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,.
推荐答案
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.
这篇关于如何在WPF DataGrid模板列中设置显示列索引?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!