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.
Unfortunately, activation email could not send to your email. Please try again.

Setting CellType for a Column in GridGroupingControl

Thread ID:

Created:

Updated:

Platform:

Replies:

15249 Jun 15,2004 09:20 AM Jun 22,2004 10:03 AM Windows Forms 8
loading
Tags: Grouping
Administrator [Syncfusion]
Asked On June 15, 2004 09:20 AM

I''m trying to assign a cell type to an entire column (excluding headers) in a GridGroupingControl using the following: myGrid.TableModel.ColStyles["MyCol"].CellType = "MyCellType"; It doesn''t work. Please could you tell me how to this. I know the cell type is registered correctly as I''m able to set it for the entire grid and it works correctly. Thanks, Ben Lamb.

Sean Greer
Replied On June 15, 2004 11:51 AM

What about: myGrid.TableDescriptor.Columns["MyCol"].Appearance.AnyRecordFieldCell.CellType = "Static"; >I''m trying to assign a cell type to an entire column (excluding headers) in a GridGroupingControl using the following: > >myGrid.TableModel.ColStyles["MyCol"].CellType = "MyCellType"; > >It doesn''t work. Please could you tell me how to this. I know the cell type is registered correctly as I''m able to set it for the entire grid and it works correctly. > >Thanks, > >Ben Lamb.

Administrator [Syncfusion]
Replied On June 15, 2004 08:15 PM

Ben, Sean is right. You should modify the Appearance object of the GridColumnDescriptor instead of modifying ColStyles. Stefan

Administrator [Syncfusion]
Replied On June 16, 2004 02:24 AM

Thanks Sean and Stefan, that works perfectly. Is there a way to prevent the custom formatting from being lost when the current cell is set to a cell with a custom renderer? On my grid, I''ve turned off selection and hidden the current cell: myGrid.TableOptions.AllowSelection = GridSelectionFlags.None; myGrid.TableModel.Options.ShowCurrentCellBorderBehavior = GridShowCurrentCellBorder.HideAlways; When the user clicks on a cell the value appears to change for no apparent reason. Thanks again, Ben.

Administrator [Syncfusion]
Replied On June 17, 2004 04:31 PM

Does setting this property help? this.gridGroupingControl1.TableControl.Model.Options.ActivateCurrentCellBehavior = GridCellActivateAction.None;

Administrator [Syncfusion]
Replied On June 18, 2004 01:49 AM

No, unfortunately the behaviour remains the same. Ben.

Administrator [Syncfusion]
Replied On June 18, 2004 02:08 PM

Hi Ben, I think Clay misunderstood your problem. The following explanation should help: When the cell gets saved the custom renderers OnSaveChanges method gets called. That method then calls CellModel.ApplyFormattedText. CellModel.ApplyFormattedText the parses the formatted text and converts it to the cell value that should be stored in the table. If you want to avoid that happening you could override the OnSaveChanges method and instead of calling the base class simple set grid.Model[rowIndex, colIndex].CellValue = ControlText; Another event you could handle would be QueryCellFormattedText (or TableControlQueryCellFormattedText). That''s when the cell value is converted to the text that should be displayed in the cell. Let me know if that wasn''t your problem and try explaining it again then. Thanks, Stefan

Administrator [Syncfusion]
Replied On June 21, 2004 08:53 AM

Hi Stefan, The grid is read-only, I tried overriding OnSaveChanges and ApplyFormattedText but neither method is ever called. The cell renderer inherits from GridStaticCellRenderer and overrides OnDraw only: protected override void OnDraw(System.Drawing.Graphics g, System.Drawing.Rectangle clientRectangle, int rowIndex, int colIndex, GridStyleInfo style) { long amount = (long)style.CellValue; style.CellValueType = typeof(string); style.Text = MyCustomFormatting.FormatAsQuantity(amount); // Highlight negative numbers in red if (amount < 0) style.TextColor = Color.Red; base.OnDraw (g, clientRectangle, rowIndex, colIndex, style); } The problem occurs as soon as you click in the cell. For example if value in the table is 20000 my custom formatting will display 20,000. As soon as the user clicks in the cell the contents change to 20000. This is even more noticable for larger numbers e.g. 1250000 is formatted as 1m250. I also modified my class that overrides GridStaticCellModel so that in the constructor I subscribe to QueryCellFormattedText events. However, I never receive any of these either. Please do you have any further suggestions? Thanks, Ben.

Administrator [Syncfusion]
Replied On June 22, 2004 10:03 AM

Hi Ben, Some suggestions: Instead of setting style.Text set style.CellValue - Or - Override the GetFormattedText(GridStyleInfo style, object value, int textInfo) method of the cell model class. That''s the method that gets called to format the text. If you have source code, try also setting a breakpoint in your Draw method. Then you can step in to the base class GridStaticCellRenderer.Draw method and see how the cell actually gets drawn. You could also try to draw the cell using the DrawText method yourself instead of calling the base class. Let me know if that didn''t help either. Stefan

CONFIRMATION

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.

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.

;