473,385 Members | 1,830 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,385 software developers and data experts.

SortedList bind to datagrid

How does one bind a SortedList to anything. If it cant be done why would
anyone ever even use a sortedlist?

We are currently (via business objects that use interfaces etc) binding
gridviews to List<T> type with zero problem which was an upgrade from our
previous methodology of doing the exact same thing with Arraylists.
However now using SortedList it doesnt work becuase it doesnt have an index
but rather a "key" which in our case is type string.

What really confuses me is that I dont understand why anyone would ever use
a SortedList<T> if it cant be bound to anything which means I am clearly
missing the point of SortedList<T>

Thanks
Mar 3 '06 #1
2 9111
nevermind!

I needed to access an index value of the sorted list and its
SortedList.Values(index)

that was all I was trying to find and I didnt even know it.

"Sean" wrote:
How does one bind a SortedList to anything. If it cant be done why would
anyone ever even use a sortedlist?

We are currently (via business objects that use interfaces etc) binding
gridviews to List<T> type with zero problem which was an upgrade from our
previous methodology of doing the exact same thing with Arraylists.
However now using SortedList it doesnt work becuase it doesnt have an index
but rather a "key" which in our case is type string.

What really confuses me is that I dont understand why anyone would ever use
a SortedList<T> if it cant be bound to anything which means I am clearly
missing the point of SortedList<T>

Thanks

Mar 3 '06 #2
Hi Sean,
when you bind to the sorted list you just need to specify what you want to
display the Key or the Value. Below is an example of a sorted list being
databound to a combo box and displaying the Value:

SortedList<int, string> myList = new SortedList<int, string>();
myList.Add(1, "one");
myList.Add(2, "two");
myList.Add(3, "three");

BindingSource bindingSource = new BindingSource();
bindingSource.DataSource = myList;

comboBox1.DisplayMember = "Value";
comboBox1.DataSource = bindingSource;

Hope that helps
Mark Dawson
http://www.markdawson.org


"Sean" wrote:
How does one bind a SortedList to anything. If it cant be done why would
anyone ever even use a sortedlist?

We are currently (via business objects that use interfaces etc) binding
gridviews to List<T> type with zero problem which was an upgrade from our
previous methodology of doing the exact same thing with Arraylists.
However now using SortedList it doesnt work becuase it doesnt have an index
but rather a "key" which in our case is type string.

What really confuses me is that I dont understand why anyone would ever use
a SortedList<T> if it cant be bound to anything which means I am clearly
missing the point of SortedList<T>

Thanks

Mar 3 '06 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
by: gerrod | last post by:
Hi - Does anyone know a way to created a SortedList (in the System.Collections namespace) that will sort on VALUES instead of KEYS... ? The scenario is this - I have a SortedList containing...
4
by: Greg Linwood | last post by:
I am wondering what the best approach to binding XML data to an asp:Table from the Page_Load event in a code behind module? I'm using VB.Net and initially approached this by adding a table to the...
6
by: coleenholley | last post by:
I have a Class Module written in VB that calls an RPC (written in COBOL) we have written code to read the data from the RPC, and we create a temporary datatable to store the data from the RPC. This...
3
by: AFN | last post by:
I need to manually create the data to be shown in a datagrid (or some data table object). Should I create an array and bind the array to the datagrid OR should I create a temporary dataset and...
7
by: Jed | last post by:
I have a web service method that returns an array of custom objects marked serializeable with fully described public properties. When I bind the results to a DataGrid I can access the properties...
17
by: A_PK | last post by:
I have problem databinding the DataGrid with DataView/DataSet after the filter... I create the following proceudre in order for user to filter as many as they want, but the following code is only...
2
by: Ori :) | last post by:
Hi Guys, I have a sortedlist which holds a group of "CartItem" items. following is the CartItem class: Public Class CartItem Public ProdID As Integer Public Name As String Public Price As...
2
by: Prez | last post by:
I started writing .net code yesterday and I am grasping it well enough. I have a few questions about SortedLists. I am using managed C++ if that makes any difference. Of the examples I...
4
by: SHEBERT | last post by:
Here is an example of a SortedList that works as a datasource to the ComboBox and a generic SortedList<that does not works as a datasource to the ComboBox. Why? If I use List and generic List<>,...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.