Solved

Datagridview - Linklabel

Posted on 2006-11-12
8
1,646 Views
Last Modified: 2013-04-11

Hi there

Is it possible to create a column in a datagridview where all the cells are shown as link labels?  If so how do I got about this

many thanks!
0
Comment
Question by:DavidGreenfield
  • 3
  • 3
  • 2
8 Comments
 
LVL 13

Expert Comment

by:newyuppie
ID: 17924860
the DataGridView allows you to do this already i believe. just right click on the datagridview, edit columns, and set the COlumnType to DataGridViewLinkColumn
0
 
LVL 10

Expert Comment

by:Kinger247
ID: 17924875
Set the column type to DataGridViewLinkColumn (for each column).
0
 
LVL 13

Expert Comment

by:newyuppie
ID: 17924880
hi kinger! only 25 more points and you get Master! congrats
0
Free Tool: Site Down Detector

Helpful to verify reports of your own downtime, or to double check a downed website you are trying to access.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

 

Author Comment

by:DavidGreenfield
ID: 17924935
How can I use the datagridviewlinkcolumn with exisitng data?

My data is being loaded form a data table,  and its on one of the columns I want turn into a link label.  I can only find information on adding a column in, not actually using the data thats already there in the table.

Can I not do this?

thanks for your help so far!
0
 
LVL 13

Expert Comment

by:newyuppie
ID: 17925012
when you are in the designer, right click and edit columns in the datagridview. select the column you want to turn into a link label, and navigate the property sheet of that column until you find ColumnType. change that to DataGridViewLinkColumn.

unless you are automatically generating the columns, in which case you must do it by code using something like this:

Dim column As DataGridViewColumn = dataGridView.Columns("Links")
        column.ColumnType = DataGridViewLinkColumn

0
 

Author Comment

by:DavidGreenfield
ID: 17925034
Hi newyuppie

I am automatically generating the columns,

but the code you gave me does not work.  It says columntype is not a member of datagridviewcolumn.  I have celltype option - but this then errors on datagridviewlinkcolumn saying its not a type and cannot be used as an expression.

thanks foryour help so far!
0
 
LVL 10

Accepted Solution

by:
Kinger247 earned 500 total points
ID: 17925035
I know of no otherway of changing the column type after you have loaded it with data.
So what I would do is loop through each cell and

1. Copy its contents locally.
2. Manually change its type.
3. Replace its contents.

Like this:

        Dim ColumnToChange As Integer = 1
        Dim CurrentValue As String

        For i As Integer = 0 To DataGridView1.Rows.Count - 1
            CurrentValue = DataGridView1(ColumnToChange, i).Value
            DataGridView1(ColumnToChange, i) = New DataGridViewLinkCell
            DataGridView1(ColumnToChange, i).Value = CurrentValue
        Next
0
 

Author Comment

by:DavidGreenfield
ID: 17925048
Kinga, that works perfectly.  Thank you very much indeed!
0

Featured Post

Free Tool: IP Lookup

Get more info about an IP address or domain name, such as organization, abuse contacts and geolocation.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Article by: Kraeven
Introduction Remote Share is a simple remote sharing tool, enabling you to see, add and remove remote or local shares. The application is written in VB.NET targeting the .NET framework 2.0. The source code and the compiled programs have been in…
Since .Net 2.0, Visual Basic has made it easy to create a splash screen and set it via the "Splash Screen" drop down in the Project Properties.  A splash screen set in this manner is automatically created, displayed and closed by the framework itsel…
Two types of users will appreciate AOMEI Backupper Pro: 1 - Those with PCIe drives (and haven't found cloning software that works on them). 2 - Those who want a fast clone of their boot drive (no re-boots needed) and it can clone your drive wh…
Nobody understands Phishing better than an anti-spam company. That’s why we are providing Phishing Awareness Training to our customers. According to a report by Verizon, only 3% of targeted users report malicious emails to management. With compan…

820 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question