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
close icon

add LinkLabel to GridDataBoundGrid

hi to all, how can i add a LinkLabel in GridDataBoundGrid column. best regards and thanks in advance fady

4 Replies

AD Administrator Syncfusion Team April 24, 2006 10:53 AM UTC

Hi Fady, LinkLabel is a Custom CellType.A custom CellType can be created, it requires a model class and a renderer class. The model class handles the serialization requirements for the control and creates the renderer class. The renderer class handles the UI requirements of the cell. This sample in \Syncfusion\Essential Studio\4.1.0.62\windows\Grid.Windows\Samples\In Depth\DerivedCellControlTutorial can be referred. After creating the custom celltype, it has to be registered through CellModels.Add gridDataBoundGrid1.Model.CellModels.Add("LinkLabelCell", new LinkLabelCellModel(gridDataBoundGrid1.Model)); You need to set the linklabel cell type using Model''s Querycell Info event handler.Here is a code snippet. if(e.ColIndex == 5 && e.RowIndex > 0) { e.Style.CellType = "LinkLabelCell"; e.Style.Tag = "http://www.google.com/"; } Here is a sample. http://www.syncfusion.com/Support/user/uploads/DataBoundGrid_8c85137b.zip For more details,See the browser sample. \Syncfusion\Essential Studio\4.1.0.62\windows\Grid.Windows\Samples\CellTypes\LinkLabelCells\cs Please let me know if this helps. Regards, Haneef


FS Fady Sayegh April 24, 2006 11:58 AM UTC

Hi Haneef, thanks to your reply, it works fady


PA Paratoo November 12, 2013 04:57 PM UTC

Hello,

I'm trying t use the LinkLabelCellModel in http://www.syncfusion.com/Support/user/uploads/DataBoundGrid_8c85137b.zip
how can I modify it in order to edit the hypelink by double clicking on cell values?
Thanks


AR Arulpriya Ramalingam Syncfusion Team March 5, 2018 12:00 PM UTC

Hi Paratoo,  
  
We have analyzed the provided sample. In the provided sample, the LinkLabelCellModel was inherited from a StaticCellModel. So, the LinkLabelCell will not be entered to edit mode at run time. If you want the cell to edit on DoubleClick, the LinkLabelCellModel can be overridden from the GridTextBoxCellModel and the LinkLabelCellRenderer can be inherited from GridTextBoxCellRenderer to enable the editing mode. Moreover, the ActivateCurrentCellBehavior can be set to DblClickOnCell to enable editing on double click. Please make use of the below code and modified sample,  
  
Code example  
  
//To enable editing on cell double click  
gridDataBoundGrid1.ActivateCurrentCellBehavior =GridCellActivateAction.DblClickOnCell;  
  
//To inherit the cell from GridTextBoxCellModel  
public class LinkLabelCellModel : GridTextBoxCellModel  
{  
            protected LinkLabelCellModel(SerializationInfo info, StreamingContext context)  
                        : base(info, context)  
            {  
            }  
//Some code  
}  
  
//To inherit the cell from GridTextBoxCellRenderer  
public class LinkLabelCellRenderer: GridTextBoxCellRenderer  
{  
            private bool _isMouseDown;  
            private bool _drawHotLink;  
            private Color _hotColor;  
            private Color _visitedColor;  
            private string _EXEname;  
  
            public LinkLabelCellRenderer(GridControlBase grid, GridCellModelBase cellModel)  
//Some code  
}  
  
  
Note  
In the provided sample, the browser for the link is launched in MouseUp event of the cell which will be called for both single and double click events. So, the browser will be launched on double click also and then the cell will be moved to edit mode.  
  
Regards,  
Arulpriya 


Loader.
Live Chat Icon For mobile
Up arrow icon