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

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

Thread ID:





30047 Jun 9,2005 04:12 PM UTC Jun 14,2005 04:15 PM UTC WinForms 5
Tags: GridControl
Administrator [Syncfusion]
Asked On June 9, 2005 04:12 PM UTC

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

Administrator [Syncfusion]
Replied On June 9, 2005 05:37 PM UTC

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

Administrator [Syncfusion]
Replied On June 13, 2005 04:12 PM UTC

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

Administrator [Syncfusion]
Replied On June 13, 2005 04:48 PM UTC

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.

Administrator [Syncfusion]
Replied On June 14, 2005 03:59 PM UTC

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

Administrator [Syncfusion]
Replied On June 14, 2005 04:15 PM UTC

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.


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

or the page will be automatically redirected to 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