This is a migrated thread and some comments may be shown as answers.

changing the edited cell background color dynamically

5 Answers 436 Views
GridView
This is a migrated thread and some comments may be shown as answers.
rajesh singh
Top achievements
Rank 1
rajesh singh asked on 25 Feb 2010, 08:29 AM

 

Hi,
  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

Sort by
0
Stefan Dobrev
Telerik team
answered on 01 Mar 2010, 11:54 AM
Hi rajesh,

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.
0
rajesh singh
Top achievements
Rank 1
answered on 01 Apr 2010, 10:34 AM
Hi Stefan,
      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






0
Stefan Dobrev
Telerik team
answered on 06 Apr 2010, 09:48 AM
Hello 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.
0
akki kumar
Top achievements
Rank 1
answered on 17 Jun 2010, 01:41 PM
Hiiiiiii
      I am Not Able To Implement this Functionality In Winform GridView
      How Can I Implement this Functionality In Winform

Thanksssss
0
Vlad
Telerik team
answered on 17 Jun 2010, 01:43 PM
Hi,

 This forum is for our WPF grid. Please post your question in the relevant forum category!

Sincerely yours,
Vlad
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
Tags
GridView
Asked by
rajesh singh
Top achievements
Rank 1
Answers by
Stefan Dobrev
Telerik team
rajesh singh
Top achievements
Rank 1
akki kumar
Top achievements
Rank 1
Vlad
Telerik team
Share this question
or