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. (Last updated on: November 16, 2018).
Unfortunately, activation email could not send to your email. Please try again.
Syncfusion Feedback

Cell readonly

Thread ID:





60821 May 11,2007 10:47 PM UTC May 12,2007 08:05 AM UTC WinForms 4
Tags: GridControl
Asked On May 11, 2007 10:47 PM UTC

Using a griddataboundgrid, I would like a cell to be locked and greyed out until another cell on the same row has valid data.

What is the best way to accomplish this?

Administrator [Syncfusion]
Replied On May 12, 2007 01:16 AM UTC

You can do this by handling grid.Model.QueryCellInfo. There, if e.RowIndex and e.ColIndex point to th ecell you want readonly, then test the value of the other cell to see if you need to set e.Style.Readonly = true.

void Model_QueryCellInfo(object sender, Syncfusion.Windows.Forms.Grid.GridQueryCellInfoEventArgs e)
if (e.RowIndex > 0 && e.ColIndex > 0)
//make Col2 readonly and gray if Col1 has a 3 in it
if (e.ColIndex == this.gridDataBoundGrid1.Binder.NameToColIndex("Col2"))
int colIndex = this.gridDataBoundGrid1.Binder.NameToColIndex("Col1");
object o = this.gridDataBoundGrid1[e.RowIndex, colIndex].CellValue;
if (o != null && o.ToString().Length > 0 &&
(int)this.gridDataBoundGrid1[e.RowIndex, colIndex].CellValue == 3)
e.Style.TextColor = SystemColors.GrayText;
e.Style.ReadOnly = true;

Replied On May 12, 2007 03:17 AM UTC

Sounds great except I don't know how to get at the event.

Replied On May 12, 2007 05:45 AM UTC

>Sounds great except I don't know how to get at the event.

I figured out that I need to add the handler manually but what triggers the event?

Administrator [Syncfusion]
Replied On May 12, 2007 08:05 AM UTC

The event is raised anytime the grid needs a cell value for any reason. So, when the grid draws the cell, the event is raised. When you move the mouse over the cell, the event is rasied. Whenever you index the grid (ie, request grid[row, col]), the event is raised. And so on.

Here are some KBs discussing QueryCellInfo.
kb 1

kb 2

kb 3


This post will be permanently deleted. Are you sure you want to continue?

Sorry, An error occured while processing your request. Please try again later.

Please sign in to access our forum

This page will automatically be redirected to the sign-in page in 10 seconds.

Warning Icon You are using an outdated version of Internet Explorer that may not display all features of this and other websites. Upgrade to Internet Explorer 8 or newer for a better experience.Close Icon