Click here to Skip to main content
11,494,407 members (63,991 online)
Rate this: bad
good
Please Sign up or sign in to vote.
See more: C# sharepoint2010
Var maxLength = (char) 10;
while(maxlength<Label.text)

Says can use < on operander like char and string Can somehelp mme=
Posted 21-Jan-13 6:01am
Kurac1861
Comments
Kishor Deshpande at 21-Jan-13 11:06am
   
Why you have put comparison in while?
It's wrong boolean operation by the way.
Rate this: bad
good
Please Sign up or sign in to vote.

Solution 1

You can't compare a char with a string!
What you actuall want to say is:
while (maxlength < myLabel.Text.Length)
Or more probably
if (maxlength < myLabel.Text.Length)
  Permalink  
Rate this: bad
good
Please Sign up or sign in to vote.

Solution 2

You are using an operator on essentially a string value, which is not allowed. You need to declare your variables with a specific datatype. Your maxLength variable needs to be an int, not a char and Label.text needs to be Label.Text.Length.
  Permalink  
Rate this: bad
good
Please Sign up or sign in to vote.

Solution 3

Label does not have a maxlength property.
The best you can do is handle the keydown event and then ensure that the count is less than 10.

For e.g.
private label1_keydown(sender o, keydowneventargs a)
{
  if (label1.Length)>10 
  {
    label1.Text = label1.Text.SubString(0,10);
  }
}
  Permalink  
Comments
Kurac1 at 21-Jan-13 15:50pm
   
Hi its not working

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

  Print Answers RSS
0 Dnyaneshwar@Pune 708
1 Sergey Alexandrovich Kryukov 369
2 CHill60 350
3 Sascha Lefèvre 255
4 Nakul Chaudhari 236
0 Sergey Alexandrovich Kryukov 10,277
1 OriginalGriff 8,805
2 Sascha Lefèvre 3,704
3 Maciej Los 3,392
4 Richard Deeming 2,500


Advertise | Privacy | Mobile
Web04 | 2.8.150520.1 | Last Updated 21 Jan 2013
Copyright © CodeProject, 1999-2015
All Rights Reserved. Terms of Service
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100