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

CellType and ClearCells Questions

I have no doubt that I'm going about this wrong, but it brought me this far... . Our grid is not data bound, but it is using the PopulateValues method to load data from an array: GridControl1.Model.PopulateValues(GridRangeInfo.Cells(0, 0, mRowCount, mColumnCount), mDataArray) The grid is used to display data three different ways. Each time the view is changed the routine with the above code is called. I start out by making all of the cells in the grid static: GridControl1.Model.TableStyle.CellType = "Static" Then I activate the rows that should be active: For RowIndex = 1 to mRowCount GridControl1.Model.RowStyles(RowIndex).CellType = "TextBox" Next And then at the end I make sure the description column is static: GridControl1.Model.ColStyles(1).CellType = "Static" GridControl1.EndUpdate() 'it starts with BeginUpdate GridControl1.Refresh() This works well enough, but in one of my views I need to turn everything the other way so I activate the rows, then before I end the update I loop through the columns and attempt to deactivate the columns I don't need: For ColumnIndex = 2 To mColumnCount 'If not the right type Then GridControl1.Model.ColStyles(ColumnIndex).CellType = "Static" 'End If Next ColumnIndex I find that while this works for the most part, I run into two problems: Unless a row's style is explicitly reset in a new view the previous view's style for that row (or cell) remains. And, when I attempt to reset the column style, the style of the row supercedes the style of the column where it has been turned on. I read Stefan's response to Reddy's posting and I now call GridControl1.Model.ClearCells(GridRangeInfo.Table, True) before I set the TableStyle.CellType. This has removed the lingering styles to an extent, but even if I call GridControl1.Model.ClearCells(GridRangeInfo.Cells(1, ColumnIndex, mRowCount, ColumnIndex), True) prior to making the column static, the rows as TextBox still exist. So, apart from asking if there's a better way to do this? Does setting a row style first override any subsequent column style modifications? And why doesn't the TableStyle or the ClearCells truly clear the cell or reset the table's style? Thanks, Tom Ps, I hope the Syncfusion crew enjoyed the snow day.

1 Reply

AD Administrator Syncfusion Team December 6, 2002 10:47 PM UTC

> I have no doubt that I'm going about this wrong, but it brought me this far... . Our grid is not data bound, but it is using the PopulateValues method to load data from an array: > > GridControl1.Model.PopulateValues(GridRangeInfo.Cells(0, 0, mRowCount, mColumnCount), mDataArray) > > The grid is used to display data three different ways. Each time the view is changed the routine with the above code is called. > > I start out by making all of the cells in the grid static: > > GridControl1.Model.TableStyle.CellType = "Static" > > Then I activate the rows that should be active: > > For RowIndex = 1 to mRowCount > GridControl1.Model.RowStyles(RowIndex).CellType = "TextBox" > Next > > And then at the end I make sure the description column is static: > > GridControl1.Model.ColStyles(1).CellType = "Static" > GridControl1.EndUpdate() 'it starts with BeginUpdate > GridControl1.Refresh() > > This works well enough, but in one of my views I need to turn everything the other way so I activate the rows, then before I end the update I loop through the columns and attempt to deactivate the columns I don't need: > > For ColumnIndex = 2 To mColumnCount > 'If not the right type Then > GridControl1.Model.ColStyles(ColumnIndex).CellType = "Static" > 'End If > Next ColumnIndex > > I find that while this works for the most part, I run into two problems: Unless a row's style is explicitly reset in a new view the previous view's style for that row (or cell) remains. And, when I attempt to reset the column style, the style of the row supercedes the style of the column where it has been turned on. > > I read Stefan's response to Reddy's posting and I now call > > GridControl1.Model.ClearCells(GridRangeInfo.Table, True) > > before I set the TableStyle.CellType. This has removed the lingering styles to an extent, but even if I call > > GridControl1.Model.ClearCells(GridRangeInfo.Cells(1, ColumnIndex, mRowCount, ColumnIndex), True) > > prior to making the column static, the rows as TextBox still exist. > > So, apart from asking if there's a better way to do this? Does setting a row style first override any subsequent column style modifications? And why doesn't the TableStyle or the ClearCells truly clear the cell or reset the table's style? > > Thanks, > Tom > > Ps, I hope the Syncfusion crew enjoyed the snow day. > Tom, There is a precedence order for style settings. As you note, row styles take precedence over column styles. This is discussed in section 3.2.1 user's manual and in the Quick Start\GridStyleInfoAtWork sample. You can run this sample and see how Standard/TableStyle/Column/Row/Cell styles interact with each other. If a row style is set, then now matter what you set as a column style, the row style will take precedence. As a possible solution to your problem, instead of trying to explicity set these styles, you can handle the QueryCellInfo event and dynamically provide the e.Style.CellType depending upon the e.RowIndex and e.ColIndex passed it. If you modify e.StyleInfo, you should also set e.Handled = true. Clay

Loader.
Live Chat Icon For mobile
Up arrow icon