DataGrid的走马灯效果

把 DataDrid放到MARQUEE 里,注意,如果要放到一个td里时,td的长度要设置的

  <<MARQUEE οnmοuseοver="this.stop()" οnmοuseοut="this.start()" scrollAmount="3" scrollDelay="0"   direction="up" height="98">>
              <asp:datagrid id="DgNews" runat="server" Width="400" AutoGenerateColumns="False" BorderWidth="0" Height="100" ShowHeader="False">
               <Columns>
                <asp:TemplateColumn HeaderText="新闻内容">
                 <HeaderStyle Width="70%"></HeaderStyle>
                 <ItemStyle Width="70%"></ItemStyle>
                 <ItemTemplate>
                  
                  <asp:Label ID="Label10" Text='<%#DataBinder.Eval(Container.DataItem,"XXSM")%>' Runat=server/>
                  (
                  <asp:Label ID="Label5" Font-Italic=True Text='<%#DataBinder.Eval(Container.DataItem,"XGRQ")%>' ForeColor=#ff7f66 Runat=server/>
                  )
                  <asp:Image ID="NewPic" Runat="server" ImageUrl="images/main/new.gif" Width="28" Height="11"></asp:Image>
                 </ItemTemplate>
                </asp:TemplateColumn>
               </Columns>
              </asp:datagrid>
             <</MARQUEE>>

在WPF(Windows Presentation Foundation)中,DataGridView是一种用于显示表格数据的用户界面控件。如果你想要实现单元格闪烁的效果,通常是在某些操作(如数据更新、输入验证等)完成后,为了吸引用户注意力或者提供反馈而添加的一种视觉提示。这可以通过自定义`DataGridCellEditingEndingEventArgs`事件处理程序来实现。 以下是一个简单的示例,展示如何在编辑结束时让单元格闪烁: ```csharp private void dataGrid_CellEditingEnded(object sender, DataGridCellEditingEndedEventArgs e) { // 获取刚刚编辑过的单元格 DataGridCell editedCell = e.EditedItem as DataGridCell; if (editedCell != null) { // 设置焦点以便看到闪烁效果 editedCell.Focus(); // 定义动画持续时间和颜色变化 Duration animationDuration = new Duration(TimeSpan.FromMilliseconds(500)); SolidColorBrush cellColor = new SolidColorBrush(Color.FromArgb(255, 255, 0, 0)); // 红色 // 创建一个颜色切换动画 Storyboard storyboard = newStoryboard(); ColorAnimation colorAnimation = new ColorAnimation( Storyboard.TargetProperty = FrameworkElement.BackgroundProperty, From = editedCell.Background.Color, To = cellColor.Color, Duration = animationDuration); // 添加动画到故事板并开始播放 storyboard.Children.Add(colorAnimation); storyboard.Begin(e.UpdatedCells[0]); // 当动画结束后,恢复原始背景色 EventHandler completedHandler = null; completedHandler = delegate { editedCell.Background = editedCell.DefaultStyleProperties[BackgroundProperty]; }; storyboard.Completed += completedHandler; } }
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值