Prevent hyphen line break in label control?
Prevent hyphen line break in label control?
Prevent hyphen line break in label control?
Prevent hyphen line break in label control?
Prevent hyphen line break in label control?
Prevent hyphen line break in label control? Prevent hyphen line break in label control? Prevent hyphen line break in label control? Prevent hyphen line break in label control? Prevent hyphen line break in label control? Prevent hyphen line break in label control? Prevent hyphen line break in label control? Prevent hyphen line break in label control?
Prevent hyphen line break in label control? Prevent hyphen line break in label control?
Prevent hyphen line break in label control?
Go Back  Xtreme Visual Basic Talk > > > Prevent hyphen line break in label control?


Reply
 
Thread Tools Display Modes
  #1  
Old 09-13-2013, 09:24 AM
DrPunk's Avatar
DrPunkPrevent hyphen line break in label control? DrPunk is offline
Senior Contributor

* Expert *
 
Join Date: Apr 2003
Location: Never where I want to be
Posts: 1,403
Default Prevent hyphen line break in label control?


I'm using a big, centered text, label control to chuck a load of text in to display.

But hyphens in the text are causing it to split the word up that contains the hyphen whereas I need it to stay as one word.

For example, the text might be "Blah blah blah blah '001-01-01'". The text is to long to fit on a single line of the label. It can get some of the '001-01-01' in but not all of it. So ends up being displayed as...
Quote:
Blah blah blah blah '001-01-
01'
... but I want it as...
Quote:
Blah blah blah blah
'001-01-01'
I know I could go about checking length of strings and what not, but I'm wondering if there is an easier way? A simple Replace or something.
__________________
There are no computers in heaven!
Reply With Quote
  #2  
Old 09-13-2013, 11:20 AM
Gruff's Avatar
GruffPrevent hyphen line break in label control? Gruff is offline
Bald Mountain Survivor

Retired Moderator
* Expert *
 
Join Date: Aug 2003
Location: Oregon, USA - deceased
Posts: 6,440
Default

I did a test with a standard label control and your words.
I cannot replicate your problem.

Have you tried inserting a newline character(s) just before and after the hyphenated word?
This should force the label to display the hyphenated word on its own line.
__________________
Burn the land and boil the sea
You can't take the sky from me


~T
Reply With Quote
  #3  
Old 09-16-2013, 06:09 AM
DrPunk's Avatar
DrPunkPrevent hyphen line break in label control? DrPunk is offline
Senior Contributor

* Expert *
 
Join Date: Apr 2003
Location: Never where I want to be
Posts: 1,403
Default

Thanks for having a look.

Turns out I couldn't recreate it either. I thought I'd quickly chuck something together to paste some code and show it. But no, couldn't do it.

OK, so something's different. But what?

Debugged the crap out of it. Everthing's exactly the same. Nothing weird about the label control I'm using. Same font. Copy stuff out of the project, paste it into other project, doesn't do the same.

Baffling.

Apart from then I notice that for some reason my project no longer has "Enable application framework" enabled. Not sure when that happened.

So I enable it again, run it, it no longer line breaks on the hyphen. Go into the project that I'm testing with to try and identify what's going on, I disable the application framework in that and bingo, that line breaks on the hyphen.

So that was it. That setting was doing that.

At least it's sorted although I'm sure why the enable application framework was turned off will come and bite me in the *** later.
__________________
There are no computers in heaven!
Reply With Quote
  #4  
Old 09-16-2013, 09:14 AM
AtmaWeapon's Avatar
AtmaWeaponPrevent hyphen line break in label control? AtmaWeapon is offline
Fabulous Florist

Forum Leader
* Guru *
 
Join Date: Feb 2004
Location: Austin, TX
Posts: 9,500
Default

That is very bizarre but I wonder if that setting doesn't change whether/how Application.SetCompatibleTextRenderingDefault() is set? That would affect text rendering and I wouldn't be /too/ surprised if how text is broken is part of that.

Personally what this would drive me to do if it were my project is make a custom label that renders the text the way I want it. It's just a handful of lines to measure the text and insert a line break, though I might just go with a permanent 2-line display depending on the space available.
__________________
.NET Resources
My FAQ threads | Tutor's Corner | Code Library
I would bet money 2/3 of .NET questions are already answered in one of these three places.
Reply With Quote
Reply


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off

Forum Jump

Advertisement:





Free Publications
The ASP.NET 2.0 Anthology
101 Essential Tips, Tricks & Hacks - Free 156 Page Preview. Learn the most practical features and best approaches for ASP.NET.
subscribe
Programmers Heaven C# School Book -Free 338 Page eBook
The Programmers Heaven C# School book covers the .NET framework and the C# language.
subscribe
Build Your Own ASP.NET 3.5 Web Site Using C# & VB, 3rd Edition - Free 219 Page Preview!
This comprehensive step-by-step guide will help get your database-driven ASP.NET web site up and running in no time..
subscribe
Prevent hyphen line break in label control?
Prevent hyphen line break in label control?
Prevent hyphen line break in label control? Prevent hyphen line break in label control?
Prevent hyphen line break in label control?
Prevent hyphen line break in label control?
Prevent hyphen line break in label control? Prevent hyphen line break in label control? Prevent hyphen line break in label control? Prevent hyphen line break in label control? Prevent hyphen line break in label control? Prevent hyphen line break in label control? Prevent hyphen line break in label control?
Prevent hyphen line break in label control?
Prevent hyphen line break in label control?
 
Prevent hyphen line break in label control?
Prevent hyphen line break in label control?
 
-->