473,395 Members | 1,688 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,395 software developers and data experts.

Dictionary Class

Hi,
I have Listbox(lstgroups) and listview(lstItems). say items in lisbox as Groups and in listview as Items.
Each Group should have list of items, when i add an new item to lstitems. it should assign to selected group. and If I add two items to a selected group and moved to Second goup and added items to these. Then if moved to first group the intial added Items are to displayed in Listview. is that Possible.
By using dictionary classes
Here List<object> should return lstitems
Dictionary<string, List<object>> d= new Dictionary(string, List<object>>();
d.add(lstgroups.items, new List<object>);
//error cumes here, how to assign here List<>

Thanks and regards,
Uday
Jan 27 '09 #1
2 1662
Plater
7,872 Expert 4TB
Create the List<object> first and then add it to the dictionary
Jan 27 '09 #2
Frinavale
9,735 Expert Mod 8TB
You need to set the DataSource for the lstItems (your ListView) when you have selected a new item in the lstgroups (your ListBox).

I'm not the greatest with C# so my example is probably not going to work if you copy paste it....but it gives you an idea of what you need to do in order to set the data source of the ListBox.
Expand|Select|Wrap|Line Numbers
  1. Dictionary<string, List<object>> d= new Dictionary(string, List<object>>();
  2.  
  3. //Create a new List of Objects that will contain the items for the selected group:
  4. List<object> groupItems= new List<object>();
  5.  
  6. //now you need to populate the "groupItems" (the list of items)  
  7. //with the items for the group.
  8. //You can do this by calling the groupItems.Add() method.
  9.  
  10. //Once finished populating the groupItems List, add it to your dictionary.
  11. d.add("key", groupItems);
  12.  
  13. //Set the data source of the ListBox to display the items:
  14. lstgroups.DataSource= d["key"];
  15.  
  16. //Or you can set it this way:
  17. //lstgroups=groupItems;
Jan 27 '09 #3

Sign in to post your reply or Sign up for a free account.

Similar topics

1
by: none | last post by:
or is it just me? I am having a problem with using a dictionary as an attribute of a class. This happens in python 1.5.2 and 2.2.2 which I am accessing through pythonwin builds 150 and 148...
4
by: brianobush | last post by:
# # My problem is that I want to create a # class, but the variables aren't known # all at once. So, I use a dictionary to # store the values in temporarily. # Then when I have a complete set, I...
2
by: jg | last post by:
I was trying to get custom dictionary class that can store generic or string; So I started with the example given by the visual studio 2005 c# online help for simpledictionay object That seem...
1
by: john wright | last post by:
I have a dictionary oject I created and I want to bind a listbox to it. I am including the code for the dictionary object. Here is the error I am getting: "System.Exception: Complex...
8
by: Brian P | last post by:
I want to expose a property of Dictionary<string, MyAbstractClass>. I tried to do it this way: private Dictionary<string, MyChildClass> _dictionary; public Dictionary<string,...
4
by: Bill Woodruff | last post by:
< note : this message was sparked in part by comments by David Browne on a previous thread : "inserting an anonymous method as a value in a generic dictionary ?" : David had shown the use of...
4
by: NullQwerty | last post by:
Hi folks, I have a Dictionary which contains a string key and an object value. I want the object value to point to a property in my class and I want it to be by reference, so that later on I...
8
by: akameswaran | last post by:
I wrote up a quick little set of tests, I was acutally comparing ways of doing "case" behavior just to get some performance information. Now two of my test cases had almost identical results which...
6
by: GiJeet | last post by:
hello, I'm trying to use a dictionary as a class member. I want to use a property to get/set the key/value of the dictionary but I'm confused as how to use a dictionary as a property. Since there...
1
by: GVDC | last post by:
Example server-side JavaScript Web script, Dictionary class //Dictionary class, hash array unlimited length configurable speed/efficiency // printf("<html><body>"); printf("<b>Creating...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
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
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: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...

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.