Click here to Skip to main content
15,883,999 members
Home / Discussions / C#
   

C#

 
GeneralRe: Calculation Pin
PIEBALDconsult11-Sep-10 4:37
mvePIEBALDconsult11-Sep-10 4:37 
GeneralRe: Calculation Pin
arkiboys11-Sep-10 4:38
arkiboys11-Sep-10 4:38 
GeneralRe: Calculation Pin
Pete O'Hanlon11-Sep-10 4:56
mvePete O'Hanlon11-Sep-10 4:56 
GeneralRe: Calculation Pin
Luc Pattyn11-Sep-10 4:52
sitebuilderLuc Pattyn11-Sep-10 4:52 
GeneralRe: Calculation Pin
OriginalGriff11-Sep-10 5:56
mveOriginalGriff11-Sep-10 5:56 
GeneralRe: Calculation Pin
Luc Pattyn11-Sep-10 6:11
sitebuilderLuc Pattyn11-Sep-10 6:11 
QuestionCheckedListBox Pin
jojoba201110-Sep-10 20:06
jojoba201110-Sep-10 20:06 
AnswerRe: CheckedListBox Pin
Tony Richards11-Sep-10 0:56
Tony Richards11-Sep-10 0:56 
Why not try something like this (not compiled, syntax errors are an exercise for the implementer!):

C#
class DataItem
{
    public string Text { get; set; }
    public string Tag { get; set; }

    public override string ToString()
    {
        return Text;
    }
}


Then:

C#
CheckedListBox.Items.Add(new DataItem { Text = "Ali", Tag = "0913279" });


If you want to change the tag, you will also be able to do:

C#
(CheckedListBox2.Items[0] as DataItem).Tag ="0913273";


This assumes that CheckedListBox2.Items[0] is a DataItem, otherwise you'll get a NullReferenceException.

You can then retrieve the item, and get the text and tag. The ToString() function is used to determine what label should be given to the item.

Note: Just reeled off of the top of my head. Untested, but I think it should work. Also assuming you're working with VS2008 or later.

Edit: It is a good idea to wrap code in <pre> or <code> tags to make them easier to read (as in my code samples).
QuestionRe: Interface and Implementing Class Relationship Pin
infinateone10-Sep-10 14:37
infinateone10-Sep-10 14:37 
AnswerRe: Interface and Implementing Class Relationship Pin
PIEBALDconsult10-Sep-10 15:07
mvePIEBALDconsult10-Sep-10 15:07 
AnswerRe: Interface and Implementing Class Relationship Pin
Luc Pattyn10-Sep-10 17:11
sitebuilderLuc Pattyn10-Sep-10 17:11 
AnswerRe: Interface and Implementing Class Relationship [modified] Pin
Paul Michalik11-Sep-10 23:04
Paul Michalik11-Sep-10 23:04 
GeneralRe: Interface and Implementing Class Relationship [modified] Pin
infinateone12-Sep-10 9:01
infinateone12-Sep-10 9:01 
GeneralRe: Interface and Implementing Class Relationship Pin
Pete O'Hanlon12-Sep-10 10:16
mvePete O'Hanlon12-Sep-10 10:16 
GeneralRe: Interface and Implementing Class Relationship Pin
infinateone12-Sep-10 10:44
infinateone12-Sep-10 10:44 
AnswerRe: Interface and Implementing Class Relationship Pin
infinateone12-Sep-10 11:07
infinateone12-Sep-10 11:07 
GeneralRe: Interface and Implementing Class Relationship Pin
Paul Michalik12-Sep-10 20:30
Paul Michalik12-Sep-10 20:30 
GeneralRe: Interface and Implementing Class Relationship Pin
infinateone13-Sep-10 4:38
infinateone13-Sep-10 4:38 
GeneralRegular Expressions Pin
Bassam Abdul-Baki10-Sep-10 3:53
professionalBassam Abdul-Baki10-Sep-10 3:53 
GeneralRe: Regular Expressions Pin
Luc Pattyn10-Sep-10 3:58
sitebuilderLuc Pattyn10-Sep-10 3:58 
GeneralRe: Regular Expressions Pin
Bassam Abdul-Baki10-Sep-10 4:09
professionalBassam Abdul-Baki10-Sep-10 4:09 
GeneralRe: Regular Expressions Pin
PIEBALDconsult10-Sep-10 4:24
mvePIEBALDconsult10-Sep-10 4:24 
GeneralRe: Regular Expressions Pin
Bassam Abdul-Baki10-Sep-10 4:26
professionalBassam Abdul-Baki10-Sep-10 4:26 
GeneralRe: Regular Expressions Pin
PIEBALDconsult10-Sep-10 4:37
mvePIEBALDconsult10-Sep-10 4:37 
GeneralRe: Regular Expressions Pin
Bassam Abdul-Baki10-Sep-10 4:46
professionalBassam Abdul-Baki10-Sep-10 4:46 

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.