Welcome to the Xceed Community | Help
Community Search  
More Search Options

Hyperlink column

Page 1 of 2 (18 items)   1 2 Next >
Sort Posts: Previous Next
  •  02-05-2010, 3:04 PM Post no. 25679

    Hyperlink column

    Is there a type of hyperlink CellViewerManager/CellEditorManager?  If so, would you show me how to create it?
    Filed under:
  •  02-05-2010, 3:59 PM Post no. 25681 in reply to 25679

    Re: Hyperlink column

    Hi Morgan,

    There is none; however, you could try to use the LinkLabel class as demonstrated in the MSDN documentation at the URL: http://msdn.microsoft.com/en-us/library/system.windows.forms.linklabel.aspx


    Xceed - Software Developer and Technical Support
  •  02-08-2010, 8:22 AM Post no. 25690 in reply to 25681

    Re: Hyperlink column

    Yes, I have used the LinkLabel class before but I am not sure how to add it to the Grid.
  •  02-08-2010, 12:18 PM Post no. 25697 in reply to 25690

    Re: Hyperlink column

    Hi Morgan,

    Find next an implementation of LinkLabel as CellViewerManager in the Xceed Grid for .NET:

    LinkLabel label = new LinkLabel();

                starterGrid.Columns[ "ProductName" ].CellViewerManager = new CellViewerManager( label, "Text" );

                starterGrid.Columns[ "ProductName" ].ReadOnly = true;

    starterGrid.DataRowTemplate.Cells[ "ProductName" ].Click += new EventHandler( StarterGrid_Click );

    void StarterGrid_Click( object sender, EventArgs e )

            {

                DataCell cell = sender as DataCell;

     

     

                if( cell.CellViewerManager.Control.GetType() == typeof( LinkLabel ) )

                {

                    LinkLabel label = cell.CellViewerManager.Control as LinkLabel;

                    // Specify that the link was visited.

                    label.LinkVisited = true;

                    // Navigate to a URL.

                    System.Diagnostics.Process.Start( "http://www.xceed.com" );

                }

            }

    ..


    Xceed - Software Developer and Technical Support
  •  02-08-2010, 3:21 PM Post no. 25699 in reply to 25697

    Re: Hyperlink column

    Thanks, this does give the look of a hyperlink but not exactly the behavior.  The mouse cursor does not change to a hand.

    Thanks anyway.

  •  02-08-2010, 3:50 PM Post no. 25701 in reply to 25699

    Re: Hyperlink column

    Hi Morgan,

    The following should address your requirements:

    LinkLabel label = new LinkLabel();

                CellViewerManager cellViewerManager = new CellViewerManager( label, "Text" );

                starterGrid.Columns[ "ProductName" ].CellViewerManager = cellViewerManager;

                starterGrid.Columns[ "ProductName" ].ReadOnly = true;

                int count = starterGrid.DataRows.Count;

                for( int i = 0; i < count; ++i )

                {

                    starterGrid.DataRows[ i ].Cells[ "ProductName" ].MouseEnter += new EventHandler( StarterGrid_MouseEnter );

                    starterGrid.DataRows[ i ].Cells[ "ProductName" ].MouseLeave += new EventHandler( StarterGrid_MouseLeave );

                }

    void StarterGrid_MouseLeave( object sender, EventArgs e )

            {

                this.starterGrid.Cursor = Cursors.Arrow;

            }

     

            void StarterGrid_MouseEnter( object sender, EventArgs e )

            {

                this.starterGrid.Cursor = Cursors.Hand;

            }


    Xceed - Software Developer and Technical Support
  •  02-08-2010, 5:06 PM Post no. 25702 in reply to 25701

    Re: Hyperlink column

    Perfect, Thanks.
  •  02-16-2010, 2:12 PM Post no. 25809 in reply to 25702

    Re: Hyperlink column

    Hi,

     

    I have a question related to this.

    In addition to click on a link, is it possible to edit it, i.e. can we have a link column that is not readonly?

     If so, how can I make the difference between clicking on a link vs starting to edit it? 

     

    Thanks,

    Marie 

  •  02-16-2010, 2:22 PM Post no. 25810 in reply to 25809

    Re: Hyperlink column

    Hi,

    You could implement a CellEditorManager on that cell using a TextBox.  You must decide on which event you want to use to open the link on a browser or on editing the Cell: by default, the editor appears when you double click on the cells. Implementing CellEditors is shown in the online documentation of the Xceed grid for .NET.


    Xceed - Software Developer and Technical Support
  •  02-16-2010, 4:28 PM Post no. 25814 in reply to 25810

    Re: Hyperlink column

    Good! Thanks.

  •  02-17-2010, 10:34 AM Post no. 25826 in reply to 25814

    Re: Hyperlink column

    Hi!

    I have another quick question...

    I am in a class that inherits of Xceed.Grid.Viewers.CellViewerManager.

    How can I set the mouse cursor from there? I don't think I can access my GridControl instance as it is done in the example... 

    This is where I am:

    public class MyCellViewerManager : Xceed.Grid.Viewers.CellViewerManager

    {

        public MyCellViewerManager() :

            base(new LinkLabel(), "Text")

        {

            this.SettingControlValue += new global::Xceed.Grid.Viewers.CellViewerEventHandler(MyCellViewerManager_SettingControlValue);

        }


        void MyCellViewerManager_SettingControlValue(object sender, Xceed.Grid.Viewers.CellViewerEventArgs e)

        {

            // Just in case, remove handlers to avoid double calls

            e.Cell.MouseLeave -= new EventHandler(Cell_MouseLeave);

            e.Cell.MouseEnter -= new EventHandler(Cell_MouseEnter);

            e.Cell.Click -= new System.EventHandler(Cell_Click);


            e.Cell.Click += new System.EventHandler(Cell_Click);     

            e.Cell.MouseEnter += new EventHandler(Cell_MouseEnter);

            e.Cell.MouseLeave += new EventHandler(Cell_MouseLeave);

        }

            

        void Cell_MouseEnter(object sender, EventArgs e)

        {

            // Change cursor here

        }


        void Cell_MouseLeave(object sender, EventArgs e)

        {

            // Change cursor back

        }


        void Cell_Click(object sender, System.EventArgs e)

        {

            // Open link :)

        }

    }

     

    Thanks a lot!

    Marie 

  •  02-17-2010, 10:53 AM Post no. 25827 in reply to 25826

    Re: Hyperlink column

    Hi Marie,

    You can get the gridControl instance via the property ParentGrid of the cell parameter of the overrided SetControlValueCore method.

    Explanation and examples on deriving the CellViewerManager are shown on the online documentation at:

    http://doc.xceedsoft.com/products/Xceedgrid/Deriving_from_the_CellViewerManager_class.html


    Xceed - Software Developer and Technical Support
  •  02-17-2010, 10:58 AM Post no. 25828 in reply to 25827

    Re: Hyperlink column

    Perfect!!! Thanks Big Smile
  •  02-17-2010, 1:01 PM Post no. 25832 in reply to 25828

    Re: Hyperlink column

    Hi!

     When I do as mentionned above:

    LinkLabel label = cell.CellViewerManager.Control as LinkLabel;

    // Specify that the link was visited.
    label.LinkVisited = true; 

    All the cells from this column get purple, not just the one I visited. Is it possible to change the LinkLabel instance of single cells?

    Thanks,

    Marie

  •  02-17-2010, 1:23 PM Post no. 25833 in reply to 25832

    Re: Hyperlink column

    Hi,

    Since the CellViewManager’s LinkLabel control is recycled on the containers of your view, changing its LinkVisited property state will affect all the cells that use it.

    The solution for your scenario is to create another Boolean field in your data item that will contain the LinkVisited state. This field will, of course, be hidden on the view.

    Then, you will handle the SettingControlAppearance event on your CellViewerManager. This even is raised when the appearance of the underlining control is about to be set.

    You will have access to the Cell and Control parameters. Using the Cell you could have access to the underlying object via the SourceObject property. That Data Item’s VisitedLink field would be updated within a Click event handler.

    Then using the Control object, you could cast it into a LinkLabel and then set its LinkVisited property to the VisistedLink field’s value.

    The above should ensure that only the click that you have visited would be purple.  


    Xceed - Software Developer and Technical Support
Page 1 of 2 (18 items)   1 2 Next >
View as RSS news feed in XML
Contact | Site Map | Reviews | Legal Terms of Use | Trademarks | Privacy Statement Copyright 2011 Xceed Software Inc.