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.

Derive control for DataBoundGrid CellType

Thread ID:

Created:

Updated:

Platform:

Replies:

9221 Dec 10,2003 05:20 PM Dec 12,2003 09:17 AM Windows Forms 4
loading
Tags: GridControl
Bryan Barton
Asked On December 10, 2003 05:20 PM

Hello, I am trying to derive a control that I have created and make it a cell type in a databound grid. So far I have figured out that I need a GridStaticCellModel and a GridStaticCellRenderer. The only examples I have to go from are the source code for the grid and the documentation. I''ve been looking at the source code for TextBoxModel and TextBoxRenderer in the Grid namespace for examples of usage. I also looked at the documentation, but it only shows how to make a linklabel cell type which only involves underlining and changing the color of the text within the cell. So far I have been unable to get my control to show up in the cell. My control will take in a DateTime system type. I want to have the control in the cell at all times and not as a floating control over the cell ( like the textbox celltype has been designed ). Can someone provide some simple sample code that can acheive this? Any help would be greatly appreciated. Thanks for your time. - Bryan Barton

Administrator [Syncfusion]
Replied On December 10, 2003 07:40 PM

Bryan, I actually don''t think you need to derive a cell rendererer. Check out the QueryCellText, SaveCellText, QueryCellFormattedText and SaveCellFormattedText events. These let you convert the object to the text to be displayed in the cell and vice versa. That way you could continue to use the normal textbox cell. But you could of course also derive from TextBoxCellModel and TextBoxCellRenderer and override the GetFormattedText, ApplyFormatedText, GetText and ApplyText methods in the CellModel class. Make sure you register any derived cell types in the GridModel.CellModels collection. Stefan

Bryan Barton
Replied On December 11, 2003 09:06 AM

Stephan Thanks for the reply. What I am trying to do is place my control (which is already built) into a DataBoundGrid Cell. I don''t want to worry about using the underlying text properties of the cell since I want the control to always be in place for that cell. Because of this reason I cannot inherit from the TextBoxCell type. I don''t see how else I can do this without creating a Model and Renderer.

Administrator [Syncfusion]
Replied On December 11, 2003 10:14 AM

Ok. What would be best if your control has a method to draw its contents to a Graphics object that you can then call from the cell rendereres OnDraw override like we do in the GridInCellRenderer.OnDraw in the In Depth\GridInCells sample. If you do not have access to such a drawing method, then you need to capture a image of the control and draw it as shown in the CellTypes\SliderCells sample. Deriving from GridGenericControlCell and setting style.Control will do that for you. Stefan

Bryan Barton
Replied On December 12, 2003 09:17 AM

Stefan, Thank you very much, I think that was exactly the examples I was looking for. I appreciate your quick responses.

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.

;