Click here to Skip to main content
15,887,214 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hi All,

I have an Arraylist a1 which has different links
a1[0]= "https://abc.com/application.aspx"
a1[1]="https://abcd123.com/application.aspx"

How can i bind this to the Datagridview ...I tried the following


VB
Dim link As New DataGridViewLinkColumn
       link.UseColumnTextForLinkValue = True
       link.HeaderText = "Link"
       link.DataPropertyName = "Link"
       link.ActiveLinkColor = Drawing.Color.White
       link.LinkBehavior = LinkBehavior.SystemDefault
       link.LinkColor = Drawing.Color.Blue
       For i As Integer = 0 To a1.count-1
                 link.Text =a1.Item(i).ToString
                dgLinkUrl.Columns.Add(link)
      Next



This adds the same link a1[0] value 3 times. But i want a1[0],a1[1],a1[2] values...Please help.
Posted
Comments
Sergey Alexandrovich Kryukov 6-Aug-13 14:15pm    
First of all, ArrayList was rendered obsolete long time ago (as of v.2.0). Use System.Collections.Generic.List.
—SA
Manas Bhardwaj 6-Aug-13 14:24pm    
Hi SA,
You are correct, but I will give him benefit of doubt. An old application in maintenance mode ? ;)
Sergey Alexandrovich Kryukov 6-Aug-13 14:28pm    
Well, yes, ArrayList was not formally marked as obsolete, only because to allow legacy support which would work fine. However, in case of any software changes (which are apparently needed due to the problem reported), it's the best to migrate to a generic collection. It's just safer.

Thank you for your note.
—SA

1 solution

This link will clear you to do that...
http://www.akadia.com/services/dotnet_arraylist_datagrid.html[^]
 
Share this answer
 
v3
Comments
vidkaat 6-Aug-13 14:35pm    
I want to create a DataGridViewLinkColumn with variable text ...
ridoy 6-Aug-13 14:40pm    
that is not anywhere in your question!See http://msdn.microsoft.com/en-us/library/system.windows.forms.datagridviewlinkcolumn.aspx
vidkaat 6-Aug-13 14:47pm    
I saw that link. But i was not sure how to set different link text to the same column. My code in the question would work perfectly if the link text is the same. But in my case it is different and i am not sure how to add each Link text to the DataGridViewLinkColumn...Hope u understand my question and help me out. Thanks a lot.
ridoy 6-Aug-13 15:09pm    
set different values in DataGridViewLinkColumn in the form's load event,see http://www.windows-tech.info/3/f7ef3d6194c4fb44.php
vidkaat 6-Aug-13 15:13pm    
Sorry I could not open the link....I appreciate ur time and help.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900