WPF DevExpress设置GridControl TableView行颜色,谢谢
展开全部
此示例展示了如何突出用户所编辑的网格单元格。当用修改一个值,然后离开所修改的单元格时,单元格背景会变红。
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控件中文网
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控件中文网
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询