Hi,
You didn't mention if the cells were if value cells, data cells, insertion cells... Also, I decided to make the grid:
gridControl1.SingleClickEdit =
true;
so a single click on a cell gets you in edit mode. Otherwise, things a more complicated.
The form1.cs gives this:
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using System.Diagnostics;
using Xceed.Grid;
namespace TestNet40
{
public partial class Form1 : Form
{
InsertionCell lastICell = null;
DataCell lastDCell = null;
public Form1()
{
Xceed.Grid.Licenser.LicenseKey = "GRD38-.......";
InitializeComponent();
}
private void Form1_Load(object sender, EventArgs e)
{
gridControl1.SingleClickEdit = true;
}
private void cell_EditEntered(object sender, EventArgs e)
{
Xceed.Grid.InsertionCell iCell = null;
if (sender is Xceed.Grid.InsertionCell)
{
iCell = (Xceed.Grid.InsertionCell)sender;
if (iCell != null)
{
gridControl1.CurrentCell.BackColor = Color.Yellow;
gridControl1.CurrentCell.ForeColor = Color.Blue;
lastICell=iCell;
}
}
Xceed.Grid.DataCell dCell = null;
if (sender is Xceed.Grid.DataCell)
{
dCell = (Xceed.Grid.DataCell)sender;
if (dCell != null)
{
gridControl1.CurrentCell.BackColor = Color.LightGray;
gridControl1.CurrentCell.ForeColor = Color.Black;
lastDCell = dCell;
}
}
Debug.WriteLine("Edit entered");
}
private void cell_EditLeft(object sender, EditLeftEventArgs e)
{
if (lastICell != null)
{
lastICell.ResetBackColor();
lastICell = null;
}
if (lastDCell != null)
{
lastDCell.ResetBackColor();
lastDCell = null;
}
Debug.WriteLine("Edit left");
}
}
}
Basically, I have put an event on the 'Edit left' and 'Edit entered' with different color depending if it's the insertion cells or the data cells. There is certainly a way to write this more efficienly.
Best regards,
Ghislain
Technical Support and software developer
Xceed Software Inc.
Knowledge Base : http://xceed.com/kb/
Update Center : http://xceed.com/updates/
Documentation Center : http://xceed.com/doc/
For everything else, there is Google