Click here to Skip to main content
15,887,888 members
Please Sign up or sign in to vote.
1.00/5 (2 votes)
See more:
I have a
C#
label.Text="inventory system"

When I resize the window it gets break like this
inventory
system

why?
Posted
Updated 11-Dec-11 18:35pm
v3
Comments
[no name] 1-Dec-11 21:11pm    
EDIT: added "pre" tag

I guess it adjusts itself according to the available width. When you minimize your screen there is less space available to display these two words in single line that is why it wraps by the space between "inventory" and "system". You can check this by removing the space between them.
 
Share this answer
 
If you don't want this should break the label. then you can fix the width of your label.
This is an alternative solution. :)
 
Share this answer
 
Comments
Member 7909353 12-Dec-11 1:22am    
It is not working fine
set the AutoSize property to true. The label will adjust its length so all the text is visible, if the label is wider than the form, the entire label will not be visible


Try this, simply modify in your code with this..

private void InitializeLabel()
	{
		this.Label1 = new Label();
		this.Label1.Location = new System.Drawing.Point(10, 10);
		this.Label1.Name = "Label1";
		this.Label1.TabIndex = 0;

		this.Label1.Size = new System.Drawing.Size(10, 10);
		this.Controls.Add(this.Label1);
		this.Label1.AutoSize = true;
		this.Label1.Text = "text" +  
			"text";

	}
 
Share this answer
 
set the AutoSize property to true. The label will adjust its length so all the text is visible, if the label is wider than the form, the entire label will not be visible
 

Try this, simply modify in your code with this..
 
private void InitializeLabel()
	{
		this.Label1 = new Label();
		this.Label1.Location = new System.Drawing.Point(10, 10);
		this.Label1.Name = "Label1";
		this.Label1.TabIndex = 0;
 
		this.Label1.Size = new System.Drawing.Size(10, 10);
		this.Controls.Add(this.Label1);
		this.Label1.AutoSize = true;
		this.Label1.Text = "text" +  
			"text";
 
	}
 
Share this answer
 
XML
<asp:Label ID="Label11" runat="server" BackColor="#99CCFF" Font-Bold="True"
         
            style="position: relative"></asp:Label>
 
Share this answer
 

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



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900