Click here to Skip to main content
15,885,546 members
Home / Discussions / C#
   

C#

 
GeneralRe: want to insert leave dates for weekdays excluding weekends from given date range using c# ASP.net Pin
OriginalGriff23-Sep-20 23:54
mveOriginalGriff23-Sep-20 23:54 
QuestionMessage Removed Pin
22-Sep-20 9:56
protectorNelek22-Sep-20 9:56 
QuestionMessage Removed Pin
23-Sep-20 6:44
mveRichard MacCutchan23-Sep-20 6:44 
QuestionWPF design UI Pin
Member 1493238422-Sep-20 5:55
Member 1493238422-Sep-20 5:55 
AnswerRe: WPF design UI Pin
Gerry Schmitz22-Sep-20 6:28
mveGerry Schmitz22-Sep-20 6:28 
QuestionBetter way to handle 50 labels Pin
Member 1494373721-Sep-20 14:54
Member 1494373721-Sep-20 14:54 
AnswerRe: Better way to handle 50 labels Pin
Richard Andrew x6421-Sep-20 16:12
professionalRichard Andrew x6421-Sep-20 16:12 
AnswerRe: Better way to handle 50 labels Pin
OriginalGriff21-Sep-20 20:58
mveOriginalGriff21-Sep-20 20:58 
One way is to add the number to the Label.Tag property - every Control has one, and it's a "free object" variable that is for the designer to use as he will.
You can then access each label very easily:
C#
Label lab = Controls.OfType<Label>().FirstOrDefault(c => Convert.ToInt32(c.Tag) == 2);
lab.Text = "Hello";

You could just use the Label.Name property, but that's messier as the VS default names do not have zero padded numbers:
Label1
Label2
...
Label10
Label11
...
So you'd need a substring and to rely on the names being in the right order on screen:
Label lab = Controls.OfType<Label>().FirstOrDefault(c => Convert.ToInt32(c.Name.Substring(5)) == 2);
lab.Text = "Hello";

"I have no idea what I did, but I'm taking full credit for it." - ThisOldTony
"Common sense is so rare these days, it should be classified as a super power" - Random T-shirt
AntiTwitter: @DalekDave is now a follower!


modified 22-Sep-20 6:08am.

AnswerRe: Better way to handle 50 labels Pin
Gerry Schmitz22-Sep-20 6:45
mveGerry Schmitz22-Sep-20 6:45 
AnswerRe: Better way to handle 50 labels Pin
BillWoodruff22-Sep-20 7:59
professionalBillWoodruff22-Sep-20 7:59 
AnswerRe: Better way to handle 50 labels Pin
Mycroft Holmes22-Sep-20 12:20
professionalMycroft Holmes22-Sep-20 12:20 
GeneralRe: Better way to handle 50 labels Pin
Member 149437371-Oct-20 18:52
Member 149437371-Oct-20 18:52 
AnswerRe: Better way to handle 50 labels Pin
Member 1494373728-Sep-20 13:41
Member 1494373728-Sep-20 13:41 
QuestionComplex View Model with Nested class Properties / Array Submit Pin
Guillermo Perez18-Sep-20 15:50
Guillermo Perez18-Sep-20 15:50 
GeneralRe: Complex View Model with Nested class Properties / Array Submit Pin
Richard MacCutchan18-Sep-20 21:47
mveRichard MacCutchan18-Sep-20 21:47 
AnswerRe: Complex View Model with Nested class Properties / Array Submit Pin
Gerry Schmitz19-Sep-20 2:43
mveGerry Schmitz19-Sep-20 2:43 
QuestionInsert on database contents of word file using OpenXML and c# Pin
cms965118-Sep-20 8:40
cms965118-Sep-20 8:40 
AnswerRe: Insert on database contents of word file using OpenXML and c# Pin
Gerry Schmitz18-Sep-20 9:36
mveGerry Schmitz18-Sep-20 9:36 
GeneralRe: Insert on database contents of word file using OpenXML and c# Pin
cms965118-Sep-20 9:52
cms965118-Sep-20 9:52 
GeneralRe: Insert on database contents of word file using OpenXML and c# Pin
Gerry Schmitz18-Sep-20 11:18
mveGerry Schmitz18-Sep-20 11:18 
GeneralRe: Insert on database contents of word file using OpenXML and c# Pin
cms965118-Sep-20 20:13
cms965118-Sep-20 20:13 
GeneralRe: Insert on database contents of word file using OpenXML and c# Pin
Dave Kreskowiak18-Sep-20 18:45
mveDave Kreskowiak18-Sep-20 18:45 
GeneralRe: Insert on database contents of word file using OpenXML and c# Pin
cms965118-Sep-20 20:11
cms965118-Sep-20 20:11 
GeneralRe: Insert on database contents of word file using OpenXML and c# Pin
Pete O'Hanlon18-Sep-20 23:10
mvePete O'Hanlon18-Sep-20 23:10 
GeneralRe: Insert on database contents of word file using OpenXML and c# Pin
Gerry Schmitz19-Sep-20 2:17
mveGerry Schmitz19-Sep-20 2:17 

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.