Click here to Skip to main content
15,921,884 members
Home / Discussions / C#
   

C#

 
Generalexport dataset to execl 2000 Pin
Wilson Wu16-Jun-04 21:28
Wilson Wu16-Jun-04 21:28 
GeneralRe: export dataset to execl 2000 Pin
Heath Stewart16-Jun-04 21:35
protectorHeath Stewart16-Jun-04 21:35 
GeneralEquivalent of SetItemData, GetItemData in C# Pin
Md Saleem Navalur16-Jun-04 20:04
Md Saleem Navalur16-Jun-04 20:04 
GeneralRe: Equivalent of SetItemData, GetItemData in C# Pin
Mazdak16-Jun-04 20:47
Mazdak16-Jun-04 20:47 
GeneralRe: Equivalent of SetItemData, GetItemData in C# Pin
Md Saleem Navalur21-Jun-04 2:44
Md Saleem Navalur21-Jun-04 2:44 
GeneralRe: Equivalent of SetItemData, GetItemData in C# Pin
Heath Stewart16-Jun-04 21:40
protectorHeath Stewart16-Jun-04 21:40 
GeneralRe: Equivalent of SetItemData, GetItemData in C# Pin
Md Saleem Navalur21-Jun-04 2:41
Md Saleem Navalur21-Jun-04 2:41 
GeneralRe: Equivalent of SetItemData, GetItemData in C# Pin
Heath Stewart21-Jun-04 3:00
protectorHeath Stewart21-Jun-04 3:00 
Well, you could start by reading the documentation for the ListBox. How do you think the regulars here learn? IntelliSense? Get real.

A ListBox takes any object, so you could design a class like so:
public class DataItem
{
  private int key;
  private string name;
  public DataItem() : this(0, null)
  {
  }
  public DataItem(int key, string name)
  {
    this.key = key;
    this.name = name;
  }
  public int Key
  {
    get { return key; }
    set { key = value; }
  }
  public string Name
  {
    get { return name; }
    set { name = value; }
  }
}
Add that to a ListBox:
listBox1.Items.Add(
  new DataItem(1, "Test 1"));
If you want to refer to it later (only works for references types):
DataItem data = listBox1.Items[0];
data.Name = "Something new";
Since it's a reference type, the Name of the referenced DataItem is changed. If you want to be able to refer to the key using ListBox.Items, then you have to extend the class and override key methods, which you can find out in the documentation.

 

Microsoft MVP, Visual C#
My Articles
GeneralRe: Equivalent of SetItemData, GetItemData in C# Pin
Md Saleem Navalur21-Jun-04 2:42
Md Saleem Navalur21-Jun-04 2:42 
GeneralRetrieving POP3 message Pin
ronin177016-Jun-04 17:19
ronin177016-Jun-04 17:19 
GeneralRe: Retrieving POP3 message Pin
palbano16-Jun-04 18:57
palbano16-Jun-04 18:57 
GeneralRe: Retrieving POP3 message Pin
Heath Stewart16-Jun-04 21:31
protectorHeath Stewart16-Jun-04 21:31 
Questionhow to scrolling through "stacked" images? Pin
ABean16-Jun-04 15:38
ABean16-Jun-04 15:38 
AnswerRe: how to scrolling through "stacked" images? Pin
Heath Stewart16-Jun-04 21:23
protectorHeath Stewart16-Jun-04 21:23 
GeneralExecption in db command..please help Pin
link_7916-Jun-04 12:24
link_7916-Jun-04 12:24 
GeneralNever mind Pin
link_7916-Jun-04 12:58
link_7916-Jun-04 12:58 
Generalcustom metadata editor using c#.net Pin
abhishk2001@yahoo.com16-Jun-04 11:53
abhishk2001@yahoo.com16-Jun-04 11:53 
GeneralRe: custom metadata editor using c#.net Pin
link_7916-Jun-04 12:36
link_7916-Jun-04 12:36 
GeneralRe: custom metadata editor using c#.net Pin
Heath Stewart16-Jun-04 13:56
protectorHeath Stewart16-Jun-04 13:56 
GeneralArcCatalog Custom metadata editor using c#.net Pin
abhishk2001@yahoo.com16-Jun-04 11:48
abhishk2001@yahoo.com16-Jun-04 11:48 
GeneralRe: ArcCatalog Custom metadata editor using c#.net Pin
Heath Stewart16-Jun-04 13:52
protectorHeath Stewart16-Jun-04 13:52 
GeneralArcCatalog Custom metadata editor using c#.net Pin
abhishk2001@yahoo.com16-Jun-04 11:45
abhishk2001@yahoo.com16-Jun-04 11:45 
GeneralUTC time to localtime Pin
Anonymous16-Jun-04 11:14
Anonymous16-Jun-04 11:14 
GeneralRe: UTC time to localtime Pin
Heath Stewart16-Jun-04 13:49
protectorHeath Stewart16-Jun-04 13:49 
Generalmy mouse up event only fires once Pin
robmays16-Jun-04 10:57
robmays16-Jun-04 10:57 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.