The Syncfusion native Blazor components library offers 70+ UI and Data Viz web controls that are responsive and lightweight for building modern web apps.
.NET PDF framework is a high-performance and comprehensive library used to create, read, merge, split, secure, edit, view, and review PDF files in C#/VB.NET.
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
ADAdministrator 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
BBBryan BartonDecember 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.
ADAdministrator 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
BBBryan BartonDecember 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.