I have a telerik gridview control in wpf. I want to highlight the cells, which are going to be edited. I have a CellValidating eventhandler, inside the event I have written the code :
GridViewCell cell = e.Cell;
cell.Background = Brushes.Green;
The color of cell is not changing, if I am moving my cursor to the different row of grid. But if I am moving cursor to different cells in the same row of grid , the color of the cells , whatever editted is changed to "Green" as I have specified in CellValidating eventhandler. In both cases, cellValidating eventhandler is getting called, but changes in background color is not happened. Can any one please help me to resolve this issue.
Regards,
Rajesh
5 Answers, 1 is accepted
I have tried to replicate this on my machine, but the cell background is changed as expected. Can you please open a support ticket and attach your application there? Also make sure you are using our latest official release.
Sincerely yours,
Stefan Dobrev
the Telerik team
Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items.
I am not able to maintain the edited cell background color. I am attaching putting code here:
window1.xaml
<Window x:Class="SetCellBackground.Window1"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:telerik="http://schemas.telerik.com/2008/xaml/presentation"
Title="Window1" Height="300" Width="300">
<Grid>
<telerik:RadGridView x:Name="RadGridView1" />
</Grid>
</Window>
Window1.xaml.cs
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Navigation;
using System.Windows.Shapes;
namespace SetCellBackground
{
/// <summary>
/// Interaction logic for Window1.xaml
/// </summary>
public partial class Window1 : Window
{
public Window1()
{
InitializeComponent();
List<Item> items = new List<Item>();
for (int i = 0; i < 10; i++)
{
items.Add(new Item() { ID = i, Name = "Name" + i });
}
this.RadGridView1.ItemsSource = items;
this.RadGridView1.CellValidating += new EventHandler<Telerik.Windows.Controls.GridViewCellValidatingEventArgs>(RadGridView1_CellValidating);
}
void RadGridView1_CellValidating(object sender, Telerik.Windows.Controls.GridViewCellValidatingEventArgs e)
{
e.Cell.Background = Brushes.Red;
}
}
public class Item
{
public int ID { get; set; }
public string Name { get; set; }
}
}
I have attached whole code. After editting the cell, i want to change the editted cell color to 'Red'. If I am editting two cells, then I want both cells color to be changed to 'Red'. So, that it is able to maintain the history of cells , those get editted.
Regards,
Rajesh
Maybe you have to change your CellValidating event handler to something like this:
void
RadGridView1_CellValidating(
object
sender, GridViewCellValidatingEventArgs e)
{
if
(e.OldValue != e.NewValue)
{
e.Cell.Background = Brushes.Red;
}
}
Best wishes,
Stefan Dobrev
the Telerik team
Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items.
I am Not Able To Implement this Functionality In Winform GridView
How Can I Implement this Functionality In Winform
Thanksssss
This forum is for our WPF grid. Please post your question in the relevant forum category!
Sincerely yours,Vlad
the Telerik team