Click here to Skip to main content
12,351,441 members (35,327 online)
Rate this:
 
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 5:01am
Kurac1866
Comments
Kishor Deshpande 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 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
Top Experts
Last 24hrsThis month


Advertise | Privacy | Mobile
Web02 | 2.8.160621.1 | Last Updated 21 Jan 2013
Copyright © CodeProject, 1999-2016
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