We use cookies to give you the best experience on our website. If you continue to browse, then you agree to our privacy policy and cookie policy. Image for the cookie policy date
close icon

CellType "ColorEdit"

when I select Color from "ColorEdit Cell Type" it should be applied to leftside of the cell

private void buttonAdv1_Click(object sender, EventArgs e)
{

DataTable newtable = new DataTable();
DataColumn dc = new DataColumn("Target Color");
// Add Columns to table
newtable.Columns.Add(dc);
newtable.Columns.Add("Source Color");
// Add rows
DataRow newrow = newtable.NewRow();
newrow["Target Color"] = " ";
newtable.Rows.Add(newrow);

this.gridDataBoundGrid1.Binder.InitializeColumns();

this.gridDataBoundGrid1.Model.ColWidths.ResizeToFit
(GridRangeInfo.EmptyRange(), GridResizeToFitOptions.NoShrinkSize);
this.gridDataBoundGrid1.DataSource = newtable;
}

private void Model_QueryCellInfo(object obj, GridQueryCellInfoEventArgs e)
{
GridStyleInfo stlinfo = new GridStyleInfo();
stlinfo.CellType = "ColorEdit";

if ( (e.RowIndex==1 || e.RowIndex==2) && e.ColIndex == 2)
{
e.Style.CellType = stlinfo.CellType;


}


1 Reply

SR Sri Rajan Syncfusion Team June 18, 2008 02:05 PM UTC

Hi Mahesh,

Thank you for your interest in Syncfusion products.

Please refer the below code to achieve this behaviour.

void gridDataBoundGrid1_CurrentCellCloseDropDown(object sender, Syncfusion.Windows.Forms.PopupClosedEventArgs e)
{
GridCurrentCell cc=this.gridDataBoundGrid1.CurrentCell;
this.gridDataBoundGrid1.CurrentCell.MoveTo(GridRangeInfo.Cell(cc.RowIndex, cc.ColIndex - 1));
}

void Model_QueryCellInfo(object sender, Syncfusion.Windows.Forms.Grid.GridQueryCellInfoEventArgs e)
{
GridStyleInfo stlinfo = new GridStyleInfo();
stlinfo.CellType = "ColorEdit";
if ((e.RowIndex == 1 || e.RowIndex == 2) && e.ColIndex == 2)
{
e.Style.CellType = stlinfo.CellType;
}
if ((e.RowIndex == 1 || e.RowIndex == 2) && e.ColIndex == 1)
{
GridStyleInfo style = this.gridDataBoundGrid1.Model[e.RowIndex, e.ColIndex + 1];
e.Style.BackColor = ColorConvert.ColorFromString(style.CellValue.ToString());
}
}


Please let me know if this helps.

Best Regards,
Srirajan



Loader.
Live Chat Icon For mobile
Up arrow icon