DevExpress控件使用交流,DevExpress中国社区Dev联系电话 联系电话:023-68661681

如何修改DevExpress DXGrid for WPF单元格的背景色?

来源:本站原创   发布时间:2012-09-04   浏览:3373次

此示例展示了如何突出用户所编辑的网格单元格。当用修改一个值,然后离开所修改的单元格时,单元格背景会变红。

C#

<Window x:Class="HighlightModifiedCells.Window1" xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" xmlns:dxg="http://schemas.devexpress.com/winfx/2008/xaml/grid" Title="How to change background color for modified cells" Height="500" Width="400">
<Window.Resources>
<Style x:Key="CellStyle" TargetType="{x:Type dxg:CellContentPresenter}">
<Setter Property="Margin" Value="1,3,1,3" />
<Setter Property="Background" Value="Transparent" />
<Setter Property="MinHeight" Value="19" />
</Style>
</Window.Resources>
<DockPanel>
<Button DockPanel.Dock="Top" Click="Button_Click">Reset</Button>
<dxg:GridControl x:Name="grid" CustomUnboundColumnData="grid_CustomUnboundColumnData">
<dxg:GridControl.Columns>
<dxg:GridColumn FieldName="Number1" />
<dxg:GridColumn FieldName="Number2" />
<dxg:GridColumn FieldName="Text1" />
<dxg:GridColumn FieldName="Text2" />
</dxg:GridControl.Columns>
<dxg:GridControl.View>
<dxg:TableView x:Name="view" AutoWidth="True" CellValueChanged="view_CellValueChanged" />
</dxg:GridControl.View>
</dxg:GridControl>
</DockPanel>
</Window>

NB.NET

<Window x:Class="HighlightModifiedCells.Window1" xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" xmlns:dxg="http://schemas.devexpress.com/winfx/2008/xaml/grid" Title="How to change background color for modified cells" Height="500" Width="400">
<Window.Resources>
<Style x:Key="CellStyle" TargetType="{x:Type dxg:CellContentPresenter}">
<Setter Property="Margin" Value="1,3,1,3" />
<Setter Property="Background" Value="Transparent" />
<Setter Property="MinHeight" Value="19" />
</Style>
</Window.Resources>
<DockPanel>
<Button DockPanel.Dock="Top" Click="Button_Click">Reset</Button>
<dxg:GridControl x:Name="grid" CustomUnboundColumnData="grid_CustomUnboundColumnData">
<dxg:GridControl.Columns>
<dxg:GridColumn FieldName="Number1" />
<dxg:GridColumn FieldName="Number2" />
<dxg:GridColumn FieldName="Text1" />
<dxg:GridColumn FieldName="Text2" />
</dxg:GridControl.Columns>
<dxg:GridControl.View>
<dxg:TableView x:Name="view" AutoWidth="True" CellValueChanged="view_CellValueChanged" />
</dxg:GridControl.View>
</dxg:GridControl>
</DockPanel>
</Window>

本站文章除注明转载外,均为本站原创或翻译
欢迎任何形式的转载,但请务必注明出处,尊重他人劳动成果
转载请注明:文章转载自:DevExpress控件中文网 [https://www.devexpresscn.com/]
本文地址:https://www.devexpresscn.com/post/322.html
在线
客服
微信
QQ 电话
023-68661681
返回
顶部