Ticket Q103247
Visible to All Users

Show URL in Grid cells

created 17 years ago

Let's say that I have two tables as follows:
Table1
pkTable1ID
fkTable2ID (this is foreign key reference to Table2 where Talbe1.fkTable2ID maps to Table2.pkTable2ID)
Table1Field_Name
Table2
pkTable2ID
Table2Field_URL (contains a URL to a website)
Now, let's say that I want to show Table1Field_Name and Table2Field_URL in a grid that is based on Table1. Neither field will be editable. I would normally set the Fieldname for the second column to fkTable2ID and then use a LookupEdit repository item to display Table2Field_URL. However, I want the user to be able to click on the URL to open up a browser to the URL. I also want the URL to look like a hyperlink. How can I accomplish this functionality?

Comments (3)
Stan (DevExpress Support) 17 years ago

    Hello Bob,
    To achieve this goal you can handle the GridView's MouseDown event as shown below:

    Visual Basic
    Private Sub GridView1_MouseDown(ByVal sender As System.Object, ByVal e As System.Windows.Forms.MouseEventArgs) Handles GridView1.MouseDown Dim hi As GridHitInfo = CType(sender, GridView).CalcHitInfo(e.X, e.Y) If hi.InRowCell AndAlso hi.Column.FieldName = "HiperLink" Then Dim link As String = CType(sender, GridView).GetRowCellDisplayText(hi.RowHandle, hi.Column) Dim pr As Process = New Process() pr.StartInfo.FileName = link pr.StartInfo.Verb = "open" pr.StartInfo.WindowStyle = ProcessWindowStyle.Normal Try pr.Start() Catch ex As Exception End Try End If End Sub

    Please try this solution and inform us of your results.
    Thanks,
    Stan.

      Thanks for the quick response.
      However, it does not appear that your proposed solution addresses the requirement that I mentioned that I want the URLs to appear as hyperlinks. How would I accomplish this?

      Stan (DevExpress Support) 17 years ago

        Hello Bob,
        Thank you for the response. To achieve this goal, you should simply adjust the Column's AppearanceCell.ForeColor and Font properties. IN the attachment you will find a sample project demonstrating this approach. Please review it and let me know if this solution meets your requirements .
        I'm looking forward to hearing from you.
        Thanks,
        Stan.

        Disclaimer: The information provided on DevExpress.com and affiliated web properties (including the DevExpress Support Center) is provided "as is" without warranty of any kind. Developer Express Inc disclaims all warranties, either express or implied, including the warranties of merchantability and fitness for a particular purpose. Please refer to the DevExpress.com Website Terms of Use for more information in this regard.

        Confidential Information: Developer Express Inc does not wish to receive, will not act to procure, nor will it solicit, confidential or proprietary materials and information from you through the DevExpress Support Center or its web properties. Any and all materials or information divulged during chats, email communications, online discussions, Support Center tickets, or made available to Developer Express Inc in any manner will be deemed NOT to be confidential by Developer Express Inc. Please refer to the DevExpress.com Website Terms of Use for more information in this regard.