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

Readonly Cell (Static)

Clay, I have 4 columns, out of 4 columns 1 column is ''Static'' cell. When we use Find & Replace, the value in the ''Static'' cell also getting changed, which basically I dont want to change. How to achieve this? Thanks Satish

11 Replies

AD Administrator Syncfusion Team July 23, 2004 11:30 AM UTC

In addition to setting style.CellType = "Static" for the column, have you tried also setting style.ReadOnly = true for that column to see if this will prevent the replace.


SA Satish July 23, 2004 11:48 AM UTC

Clay, Thanks it worked. Another Question. I have 3 Columns Example RowNumber A B C(C=A+B) 1 10 10 20 2 30 10 40 3 20 10 30 Is there any way, i need to see the output value of C without writing any code. Note : User can change the value in A & B. But output should be varied based on A & B Value. Thanks Satish >In addition to setting style.CellType = "Static" for the column, have you tried also setting style.ReadOnly = true for that column to see if this will prevent the replace.


AD Administrator Syncfusion Team July 23, 2004 12:20 PM UTC

If this is a GridDataBoundGrid, you can add a new DataColumn to the DataTable and set its Expression property to compute [A] + [B]. Then you would use this column as column C. If this is a GridControl, you could set the style.CellType for column 3 to be "FormulaCell". Then you could loop from row = 1 to grid.RowCound setting grid[row, 3].Text = string.Format("= A{0} + B{0}", row);


SA Satish July 26, 2004 07:54 AM UTC

How to prevent user to rightclick on the static cell column and focus should not be set for the static cell. Thanks Satish >If this is a GridDataBoundGrid, you can add a new DataColumn to the DataTable and set its Expression property to compute [A] + [B]. Then you would use this column as column C. > >If this is a GridControl, you could set the style.CellType for column 3 to be "FormulaCell". Then you could loop from row = 1 to grid.RowCound setting > >grid[row, 3].Text = string.Format("= A{0} + B{0}", row); >


AD Administrator Syncfusion Team July 26, 2004 07:58 AM UTC

You can try setting style.Enabled = false on that cell to see if that does what you want.


SA Satish July 26, 2004 09:09 AM UTC

No Luck. Same problem. At any cost user should not able to select that particular column (Static Cell) I tried putting readonly, enabled.. Thanks Satish >You can try setting style.Enabled = false on that cell to see if that does what you want.


AD Administrator Syncfusion Team July 26, 2004 09:32 AM UTC

Static + Enabled=false seems to work in this sample. You cannot click the colored column or move the currentcell into the column. DisableCol2_6844.zip


SA Satish July 26, 2004 10:54 AM UTC

Thanks. But even I should not select the row also. Nothing needs to be selected in that column. Thanks Satish >Static + Enabled=false seems to work in this sample. You cannot click the colored column or move the currentcell into the column. >DisableCol2_6844.zip > >


AD Administrator Syncfusion Team July 26, 2004 12:03 PM UTC

If you do not want certain cells selected when you select a range of cells, then you can handle grid.Model.SelectionChanging and cancel the selection when the range intersects the cells you do not want selected. (This is different than wanting a cell not to become current or get input focus.) private void Model_SelectionChanging(object sender, GridSelectionChangingEventArgs e) { if(e.Range.IntersectsWith(GridRangeInfo.Col(2))) e.Cancel = true; }


SA Satish July 27, 2004 10:24 AM UTC

Clay, If i use the SelectionChanging event, I am not able to select the multiple row. So how to select multiple row. Note : Row will contain read (Static) only cells. Thanks Satish >If you do not want certain cells selected when you select a range of cells, then you can handle grid.Model.SelectionChanging and cancel the selection when the range intersects the cells you do not want selected. (This is different than wanting a cell not to become current or get input focus.) > > >private void Model_SelectionChanging(object sender, GridSelectionChangingEventArgs e) >{ > if(e.Range.IntersectsWith(GridRangeInfo.Col(2))) > e.Cancel = true; >} > > >


AD Administrator Syncfusion Team July 27, 2004 10:37 AM UTC

I am confused. The reason for using the SelectionsChanging event was to avoid selecting something in column 2. I do not know how you will be able to select a row (or several rows), and still not select anything in column 2. Selecting a row, selects the cell in column 2. Is it that you want to select everything in the row except column 2? If so, then remove the SelectionChanging event, and use the technique in this forum thread to color the selection. But in your PrepareViewStyleInfo, in addition to the check that the cell is in the Selections, also check that the cell is not in column 2. http://www.syncfusion.com/Support/Forums/message.aspx?MessageID=13587

Loader.
Live Chat Icon For mobile
Up arrow icon