Home Forums WinForms controls Xceed Grid for WinForms Column value as link Reply To: Column value as link

User (Old forums)
Post count: 23064

You can simply wrap a LinkLabel control in a CellEditorManager and a CellViewerManager on that column, and handle its click event.


    private void Form1_Load(object sender, System.EventArgs e)
      gridControl1.SingleClickEdit = true;
      LinkLabel link = new LinkLabel();    
      link.LinkColor = Color.Red;

      gridControl1.Columns[ 1 ].CellEditorManager = new CellEditorManager( link, “Text”, true, true );
      gridControl1.Columns[ 1 ].CellViewerManager = new CellViewerManager( new LinkLabel(), “Text” );

      //need to handle these events to get to the LinkLabel click
      gridControl1.Columns[ 1 ].CellEditorManager.ActivatingControl += new CellEditorEventHandler(CellEditorManager1_ActivatingControl);
      gridControl1.Columns[ 1 ].CellEditorManager.DeactivatingControl += new CellEditorEventHandler(CellEditorManager1_DeactivatingControl);

    private void CellEditorManager1_ActivatingControl(object sender, CellEditorEventArgs e)
      ( ( LinkLabel )e.Control).LinkClicked += new LinkLabelLinkClickedEventHandler( LinkEditorManager_LinkClicked );

    private void CellEditorManager1_DeactivatingControl(object sender, CellEditorEventArgs e)
      //need to unsubscribe, if not, the subscribtions will kept pilling up!
      ( ( LinkLabel )e.Control).LinkClicked -= new LinkLabelLinkClickedEventHandler( LinkEditorManager_LinkClicked );

    private void LinkEditorManager_LinkClicked( object sender, LinkLabelLinkClickedEventArgs e )
      System.Diagnostics.Debug.WriteLine( “Cell Link Clicked!” );


Imported from legacy forums. Posted by André (had 2498 views)