Click here to Skip to main content
15,896,527 members
Home / Discussions / C#
   

C#

 
AnswerRe: how to get single item in foreach loop ?? Pin
Martin#24-Aug-06 21:41
Martin#24-Aug-06 21:41 
GeneralRe: how to get single item in foreach loop ?? Pin
sikandarhayat24-Aug-06 21:54
sikandarhayat24-Aug-06 21:54 
AnswerRe: how to get single item in foreach loop ?? [modified] Pin
Martin#24-Aug-06 22:16
Martin#24-Aug-06 22:16 
GeneralRe: how to get single item in foreach loop ?? Pin
sikandarhayat25-Aug-06 0:04
sikandarhayat25-Aug-06 0:04 
AnswerRe: how to get single item in foreach loop ?? Pin
Guffa25-Aug-06 0:08
Guffa25-Aug-06 0:08 
AnswerRe: how to get single item in foreach loop ?? Pin
Coding C#25-Aug-06 3:15
Coding C#25-Aug-06 3:15 
AnswerRe: how to get single item in foreach loop ?? Pin
Ennis Ray Lynch, Jr.25-Aug-06 3:22
Ennis Ray Lynch, Jr.25-Aug-06 3:22 
AnswerRe: how to get single item in foreach loop ?? Pin
Scott Dorman1-Sep-06 14:08
professionalScott Dorman1-Sep-06 14:08 
Since you mentioned that clsLabelCollection inherits from CollectionBase, it should have a Contains and an IndexOf method.

Assuming that both of these are actually implemented in the collection class, you can use them to find a specific clsLabels instance:

clsLabels l = null;
if (m_clsLabelCollection.Contains("value"))
{
int i = m_clsLabelCollection.IndexOf("value");
l = m_clsLabelCollection[i];
}

You can also iterate over the collection (using foreach) and explicitly test to see if the current item is equal to the one you want. When you find the match, break out of the loop.

This would be something like this:

clsLabels l = null;
foreach(clsLabels lbl in m_clsLabelCollection)
{
if (lbl.label == "value")
{
l = lbl;
break;
}
}

I'm assuming that lbl.label is a string field and that you are looking for the label "value".
QuestionGraphicsState and hardware Pin
s o v a n n24-Aug-06 21:25
s o v a n n24-Aug-06 21:25 
AnswerRe: GraphicsState and hardware Pin
leppie25-Aug-06 0:30
leppie25-Aug-06 0:30 
QuestionListBox With Tree Pin
Aslam Bari24-Aug-06 21:05
Aslam Bari24-Aug-06 21:05 
GeneralRe: ListBox With Tree Pin
CooperWu24-Aug-06 23:19
CooperWu24-Aug-06 23:19 
QuestionDateTime.ParseExact method query [modified] Pin
chandler8324-Aug-06 20:48
chandler8324-Aug-06 20:48 
AnswerRe: DateTime.ParseExact method query Pin
Guffa24-Aug-06 21:57
Guffa24-Aug-06 21:57 
QuestionGet Form's textBox value into Crystal Reports text Object Pin
M Riaz Bashir24-Aug-06 19:53
M Riaz Bashir24-Aug-06 19:53 
AnswerRe: Get Form's textBox value into Crystal Reports text Object Pin
Coding C#24-Aug-06 20:26
Coding C#24-Aug-06 20:26 
Questionget char from KeyChar Pin
Tyrus18224-Aug-06 18:47
Tyrus18224-Aug-06 18:47 
AnswerRe: get char from KeyChar Pin
Martin#24-Aug-06 19:15
Martin#24-Aug-06 19:15 
GeneralRe: get char from KeyChar Pin
Tyrus18224-Aug-06 19:23
Tyrus18224-Aug-06 19:23 
GeneralRe: get char from KeyChar Pin
Martin#24-Aug-06 19:27
Martin#24-Aug-06 19:27 
QuestionCan not bind the data to the list view Pin
Sri harini24-Aug-06 18:37
Sri harini24-Aug-06 18:37 
Questiondisable paste in a textbox Pin
Tyrus18224-Aug-06 18:04
Tyrus18224-Aug-06 18:04 
AnswerRe: disable paste in a textbox Pin
Martin#24-Aug-06 19:20
Martin#24-Aug-06 19:20 
GeneralRe: disable paste in a textbox Pin
Tyrus18224-Aug-06 19:28
Tyrus18224-Aug-06 19:28 
AnswerRe: disable paste in a textbox Pin
Martin#24-Aug-06 19:59
Martin#24-Aug-06 19:59 

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.