找回密码
 立即注册

QQ登录

只需一步,快速开始

feiyan0320

中级会员

17

主题

70

帖子

615

积分

中级会员

积分
615

活字格认证微信认证勋章

QQ
feiyan0320
中级会员   /  发表于:2016-3-11 23:30  /   查看:3209  /  回复:4
<c1:C1DataGrid Margin="2,4,2,5" Grid.Row="2" Grid.ColumnSpan="6" ScrollMode="Deferred"
                       x:Name="grid" ItemsSource="{Binding CVList}"  Background="Transparent"
                                     VerticalScrollBarVisibility="Visible" HeaderBackground="aleTurquoise"
                                   AutoGenerateColumns="False"
                               SelectionMode="MultiRange" HeadersVisibility="None" RowBackground="Transparent"
                               CanUserAddRows="False"   AlternatingRowBackground="Transparent"
                               CanUserFreezeColumns="Left"  RowHeight="Auto"
                               FrozenTopRowsCount="3" ScrollPreviewRowTemplate="{StaticResource MyScrollPreviewRowTemplate}"
                               FrozenColumnCount="2" IsReadOnly="True" Width="Auto" GridLinesVisibility="All" >
            <c1:C1DataGrid.Columns>
                <c1ataGridRowHeaderColumn Header="[序号, 序号]"  CanUserSort="True"
                                       Width="Auto"   Binding="{Binding Id}">
                    <c1ataGridRowHeaderColumn.CellStyle>
                        <Style TargetType="c1ataGridCellPresenter">
                            <Setter Property="Foreground" Value="Red"/>
                        </Style>
                    </c1ataGridRowHeaderColumn.CellStyle>
                </c1ataGridRowHeaderColumn>

4 个回复

倒序浏览
Alice
社区贡献组   /  发表于:2016-3-14 10:16:35
沙发
你说的是这句代码没有起作用?
  1. <Setter Property="Foreground" Value="Red"/>
复制代码


印象中这个问题讨论过,我去找找当时的帖子。
设置RowHeader可以用下面的代码:
  1.         void grid_LoadedCellPresenter(object sender, DataGridCellEventArgs e)
  2.         {
  3.             if (e.Cell.Presenter.Content.GetType() == typeof(C1.WPF.DataGrid.DataGridRowHeaderPresenter))
  4.             {
  5.                 e.Cell.Presenter.Foreground = Brushes.Red;
  6.                  }
  7.         }
复制代码
请点击评分,对我的服务做出评价!  5分为非常满意!

葡萄城控件服务团队

官方网站: http://www.gcpowertools.com.cn
回复 使用道具 举报
Alice
社区贡献组   /  发表于:2016-3-14 14:21:33
板凳
之前的帖子没查到。
我做了个示例,你看看。

本帖子中包含更多资源

您需要 登录 才可以下载或查看,没有帐号?立即注册

x
请点击评分,对我的服务做出评价!  5分为非常满意!

葡萄城控件服务团队

官方网站: http://www.gcpowertools.com.cn
回复 使用道具 举报
feiyan0320
中级会员   /  发表于:2016-3-14 22:27:55
地板
Alice 发表于 2016-3-14 14:21
之前的帖子没查到。
我做了个示例,你看看。

hi,再问下,因为我的列比较多,是否只有一种用代码来使前景色生效的办法
回复 使用道具 举报
Alice
社区贡献组   /  发表于:2016-3-15 09:13:34
5#
feiyan0320 发表于 2016-3-14 22:27
hi,再问下,因为我的列比较多,是否只有一种用代码来使前景色生效的办法

不太理解一种方法生效的意思。
C1DataGrid有提供RowForeground属性,设置后所有的前景色会变化。
请点击评分,对我的服务做出评价!  5分为非常满意!

葡萄城控件服务团队

官方网站: http://www.gcpowertools.com.cn
回复 使用道具 举报
您需要登录后才可以回帖 登录 | 立即注册
返回顶部