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

GridDataBoundGrid.Model.ColWidths.ResizeToFit does not take into account bold text

I have a GridDataBoundGrid where in the PreprareViewStyle event, some rows are conditionally bolded. Whe I call gdbg.Model.ColWidths.ResizeToFit(GridRangeInfo.Table()), the last character in bold cells which are the longest cell in the column is cut-off. Is there a work-around for this? Thanks

5 Replies

AD Administrator Syncfusion Team June 9, 2005 12:37 PM

Try using grid.Model.QueryCellInfo to set your bold text instead of grid.PrepareViewStyleInfo. (The PrepareViewStyleInfo code will probably work in the QueryCellInfo event).


AD Administrator Syncfusion Team June 13, 2005 11:12 AM

Thanks Clay, Using the GDBG.Model.QueryCellInfo event to conditionally set e.Style.Font.Bold = true solved the problem with the GDBG.Model.ColWidths.ResizeToFit. Unfortunately, this has cuased another issue to arise. Now when I actually click on the grid it is unresponsive for a few seconds, and then it turns into a white empty box with a red "X" running through int. The situation is: 1. I have a DataTable bound to a DataView, which has several columns hidden (using ColumnMapping = MappingType.Hidden). 2.The DataView is the DataSource for a GDBG, and one of the hidden columns contains a boolean that indicates if the row should be bold. I use the following code in the GDBG.Model.QueryCellInfo to format the cell font: if (e.RowIndex == 0 || e.ColIndex == 0} return; GridDataBoundGrid grid = this.myGrid; CurrencyMAnager cm = (CurrencyManager)grid.BindingContext[grid.DataSource, grid.DataMember]; DataView dv = (DataView) cm.List; int position = grid.Binder.RowIndexToPosition(e.RowIndex); DataRow dr = (DataRow) dv[position].Row; e.Style.Font.Bold = (bool) dr["Mandatory"]; 3. Note: Some cells in the grid are editable, and some are not. This is managed by conditionally cancelling the CurrentCellStartEditing event. There is also a RowFilter on the DataView which is turned on and off by the user. Is there perhaps another way to apply the bold formatting that woould not cause this behaviour? When I comment out the code in the GDBG.Model.QueryCellInfo event, I have no behaviour/performance problems with the grid. Any help is greatly appreciated! Dave


AD Administrator Syncfusion Team June 13, 2005 11:48 AM

This read is caused by an exception being thrown when the grid is drawing. Set you project to break into the debugger when an exceptions is encounterered. This should display a callstack when you hit this exception, and maybe the call stack will point to the problem and you will be able to avoid it by adding some conditional code. If you cannot spot something, if you post the call stack, maybe we can see something here.


AD Administrator Syncfusion Team June 14, 2005 10:59 AM

It appears that within the GridDataBoundGrid.Model.QueryCellInfo event that there were cases where e.RowIndex = -1. I was already returning when e.RowIndex = 0 (so that column header text would not be bold), but I am surprised that it is even possible for e.RowIndex to equal -1. I''ve adjusted my code to return on e.RowIndex <= 0, and now it works fine. What causes e.RowIndex = -1? I don''t understand how that is even possible. Thanks, Dave


AD Administrator Syncfusion Team June 14, 2005 11:15 AM

e.RowIndex = -1 and e.ColIndex > -1 are for column style requests. e.RowIndex > 0 and e.ColIndex = -1 are for row style requests. Both -1 is a tablestyle request.

Loader.
Live Chat Icon For mobile
Up arrow icon