Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

Datagridview - Linklabel

Posted on 2006-11-12
8
Medium Priority
?
1,760 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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
Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 

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 2000 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

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

If you're writing a .NET application to connect to an Access .mdb database and use pre-existing queries that require parameters, you've come to the right place! Let's say the pre-existing query(qryCust) in Access takes a Date as a parameter and l…
Parsing a CSV file is a task that we are confronted with regularly, and although there are a vast number of means to do this, as a newbie, the field can be confusing and the tools can seem complex. A simple solution to parsing a customized CSV fi…
Add bar graphs to Access queries using Unicode block characters. Graphs appear on every record in the color you want. Give life to numbers. Hopes this gives you ideas on visualizing your data in new ways ~ Create a calculated field in a query: …
In this video, Percona Solution Engineer Rick Golba discuss how (and why) you implement high availability in a database environment. To discuss how Percona Consulting can help with your design and architecture needs for your database and infrastr…
Suggested Courses

661 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