Wrox Programmer Forums
Go Back   Wrox Programmer Forums > C# and C > C# 4.0 aka C# 2010 > BOOK: Beginning Visual C# 2010
|
BOOK: Beginning Visual C# 2010
This is the forum to discuss the Wrox book Beginning Visual C# 2010 by Karli Watson, Christian Nagel, Jacob Hammer Pedersen, Jon D. Reid, Morgan Skinner, ; ISBN: 9780470502266
Welcome to the p2p.wrox.com Forums.

You are currently viewing the BOOK: Beginning Visual C# 2010 section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old January 21st, 2012, 12:05 PM
Registered User
 
Join Date: Sep 2008
Posts: 3
Thanks: 0
Thanked 0 Times in 0 Posts
Question What control do I use for a sorted list to make a column clickable

I have a windows form app .NET 4 written in C# that runs a number of HTTP requests collecting data about various websites and then once finished I order the results with some LINQ e.g

Code:
if (this.Accounts.Count > 0)
{

	// re-order list decending by No
	var lengths = from element in this.Accounts
		      orderby element.No descending
		      select element;


	foreach (AccountName ht in lengths)
	{
	    name = ht.AccountName;
	    nocount = ht.No; // no I am ordering by


	    if (!String.IsNullOrEmpty(name))
	    {
		link = "http://somelink.com/" + name;
			
		// add the item to my function that appends rows to a listview
		this.AddAccountNameToList(name, nocount, link);

	    }
	}
}
and then I call a function to add the items sorted by the No descending (most at the top of the list) to the list view. As the app is multi threaded I use a delegate to actually add each item to the listview e.g

Code:
// add list to listview (which I want the link column to be a real link)
 private void AddAccountNameToList(string AccountName, int count, string Link)
{
    ListViewItem listViewItem1 = new ListViewItem();
    ListViewItem.ListViewSubItem listViewSubItem1 = new ListViewItem.ListViewSubItem();
    ListViewItem.ListViewSubItem listViewSubItem2 = new ListViewItem.ListViewSubItem();
		 
    // format values for the row
    listViewItem1.Text = AccountName;            
    listViewSubItem1.Text = count.ToString("N0");
    listViewSubItem2.Text = Link.ToString();

    // add the two other columns to the list view
    listViewItem1.SubItems.Add(listViewSubItem1);
    listViewItem1.SubItems.Add(listViewSubItem2);
    
    // add the list view item to the list view - mulit threaded so I need to use a delegate
    this.AddAccountName(listViewItem1);   
    
}

// adds list item to listview
private void AddAccountName(ListViewItem ListItem)
{
    if (this.listViewAccountNames.InvokeRequired)
    {
	AddAccountNameCallback d = new AddAccountNameCallback(AddAccountName);
	this.Invoke(d, new object[] { ListItem });
    }
    else
    {
	this.listViewAccountNames.Items.Add(ListItem);
    }
}
Problem is that I want the actual link (3rd column) to be a clickable link that takes the user off to the URL I set.

How do I do this? Do I need to use a different control instead of a ListView like a Panel or can I add Link Elements as items into the ListView (I tried but failed with that)

any help would be much appreciated.

Thanks





Similar Threads
Thread Thread Starter Forum Replies Last Post
Make sitemap child nodes clickable in menu jmiguy ASP.NET 3.5 Basics 0 December 18th, 2009 10:21 PM
Trying to sort within a sorted list. rabs XSLT 10 March 4th, 2009 01:16 PM
How to list files in the folder? -Sorted- Mantis PHP How-To 2 April 29th, 2005 06:17 AM
Make a control Clickable Hal Levy ASP.NET 1.0 and 1.1 Basics 3 November 7th, 2003 01:24 PM
Search in a sorted list yajleejnus Classic ASP Basics 0 June 11th, 2003 04:00 PM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.