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

Derive control for DataBoundGrid CellType

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

4 Replies

AD Administrator Syncfusion Team December 11, 2003 12:40 AM UTC

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


BB Bryan Barton December 11, 2003 02:06 PM UTC

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.


AD Administrator Syncfusion Team December 11, 2003 03:14 PM UTC

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


BB Bryan Barton December 12, 2003 02:17 PM UTC

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

Loader.
Up arrow icon