|
| Author |
Message |
spitapps
Joined: 04 Oct 2007 Posts: 3
|
Posted: Mon Oct 09, 2006 4:48 pm Post subject: bold text in label |
|
|
I am putting text in a label as a variable. But i want just the
variable text to be bold face, so like:
The variable is value of the variable blah blah.
Archived from group: microsoft>public>vb>syntax |
|
| Back to top |
|
 |
Bob Butler
Joined: 04 Oct 2007 Posts: 1325
|
Posted: Mon Oct 09, 2006 4:53 pm Post subject: Re: bold text in label |
|
|
"spitapps" wrote in message@m7g2000cwm.googlegroups.com
> I am putting text in a label as a variable. But i want just the
> variable text to be bold face, so like:
>
> The variable is value of the variable blah blah.
Label1.FontBold = True
-or-
Label1.Font.Bold = True
--
Reply to the group so all can participate
VB.Net: "Fool me once..." |
|
| Back to top |
|
 |
spitapps
Joined: 04 Oct 2007 Posts: 3
|
Posted: Mon Oct 09, 2006 5:13 pm Post subject: Re: bold text in label |
|
|
Bob Butler wrote:
> "spitapps" wrote in message
> @m7g2000cwm.googlegroups.com
> > I am putting text in a label as a variable. But i want just the
> > variable text to be bold face, so like:
> >
> > The variable is value of the variable blah blah.
>
> Label1.FontBold = True
> -or-
> Label1.Font.Bold = True
>
> --
> Reply to the group so all can participate
> VB.Net: "Fool me once..."
No i mean like i want half of the text to be bold and the other half
not bold. |
|
| Back to top |
|
 |
Karl E. Peterson
Joined: 04 Oct 2007 Posts: 4836
|
Posted: Mon Oct 09, 2006 5:18 pm Post subject: Re: bold text in label |
|
|
spitapps wrote:
> Bob Butler wrote:
>>> I am putting text in a label as a variable. But i want just the
>>> variable text to be bold face, so like:
>>>
>>> The variable is value of the variable blah blah.
>>
>> Label1.FontBold = True
>> -or-
>> Label1.Font.Bold = True
>
> No i mean like i want half of the text to be bold and the other half
> not bold.
Then you'll need to roll yer own UserControl. That's not supported in the
standard Label control.
--
Working without a .NET?
http://classicvb.org/ |
|
| Back to top |
|
 |
spitapps
Joined: 04 Oct 2007 Posts: 3
|
Posted: Mon Oct 09, 2006 5:34 pm Post subject: Re: bold text in label |
|
|
Bob Butler wrote:
> "spitapps" wrote in message
> @m7g2000cwm.googlegroups.com
> > I am putting text in a label as a variable. But i want just the
> > variable text to be bold face, so like:
> >
> > The variable is value of the variable blah blah.
>
> Label1.FontBold = True
> -or-
> Label1.Font.Bold = True
>
> --
> Reply to the group so all can participate
> VB.Net: "Fool me once..."
No i mean like i want half of the text to be bold and the other half
not bold. |
|
| Back to top |
|
 |
"Rick Rothstein \
Joined: 04 Oct 2007 Posts: 1584
|
Posted: Mon Oct 09, 2006 8:42 pm Post subject: Re: bold text in label |
|
|
>> > I am putting text in a label as a variable. But i want just the
>> > variable text to be bold face, so like:
>> >
>> > The variable is value of the variable blah blah.
>>
>> Label1.FontBold = True
>> -or-
>> Label1.Font.Bold = True
>>
>> --
>> Reply to the group so all can participate
>> VB.Net: "Fool me once..."
>
> No i mean like i want half of the text to be bold and the other half
> not bold.
You can't... a Label doesn't support that functionality. You might consider
using a TextBox with the Locked property set to True.
Text1.Text = "The variable is XXX blah blah."
Text1.SelStart = InStr(Text1.Text, "XXX")
Text1.SelLength = 3
Text1.SelText = StringVariable
Text1.SelBold = True.
At this point, you can either do this
Text1.SelStart = Len(Text1.Text)
to get rid of the selection and place the caret at the end of the text. Or,
you can SetFocus to some other control completely. Whatever you do, I would
do it in a Subroutine and always use XXX (or whatever set of characters you
feel won't ever appear naturally in your text strings)...
Sub FakeLabel(TBox As TextBox, Caption As String, Replacement As String)
With TBox
.Text = Caption
.SelStart = InStr(.Text, "XXX")
.SelLength = 3
.SelText = Replacement
.SelBold = True
.SelStart = Len(Text1.Text) ' or OtherControl.SetFocus
End With
End Sub
This way, your inline code only has to do this...
FakeLabel Text1, "The variable is XXX blah blah.", SomeTextVariable
Rick |
|
| Back to top |
|
 |
Karl E. Peterson
Joined: 04 Oct 2007 Posts: 4836
|
Posted: Mon Oct 09, 2006 5:55 pm Post subject: Re: bold text in label |
|
|
Rick Rothstein (MVP - VB) wrote:
>>>> I am putting text in a label as a variable. But i want just the
>>>> variable text to be bold face, so like:
>>>>
>>>> The variable is value of the variable blah blah.
>>>
>>> Label1.FontBold = True
>>> -or-
>>> Label1.Font.Bold = True
>>
>> No i mean like i want half of the text to be bold and the other half
>> not bold.
>
> You can't... a Label doesn't support that functionality. You might
> consider using a TextBox with the Locked property set to True.
You mean a RichTextBox?
--
Working without a .NET?
http://classicvb.org/ |
|
| Back to top |
|
 |
"Rick Rothstein \
Joined: 04 Oct 2007 Posts: 1584
|
Posted: Mon Oct 09, 2006 9:08 pm Post subject: Re: bold text in label |
|
|
>>>>> I am putting text in a label as a variable. But i want just the
>>>>> variable text to be bold face, so like:
>>>>>
>>>>> The variable is value of the variable blah blah.
>>>>
>>>> Label1.FontBold = True
>>>> -or-
>>>> Label1.Font.Bold = True
>>>
>>> No i mean like i want half of the text to be bold and the other half
>>> not bold.
>>
>> You can't... a Label doesn't support that functionality. You might
>> consider using a TextBox with the Locked property set to True.
>
> You mean a RichTextBox?
Yeah... I was thinking RichTextBox and writing TextBox. Thanks for catching
that.
Corrected code for 'spitapps' (with a minor changes to make it work
correctly)...
Sub FakeLabel(RTBox As RichTextBox, Caption As String, _
Replacement As String)
With RTBox
.Text = Caption
.Find "XXX"
.SelBold = True
.SelText = Replacement
.SelStart = Len(Text1.Text) ' or OtherControl.SetFocus
End With
End Sub
Rick |
|
| Back to top |
|
 |
Sakkie
Joined: 04 Oct 2007 Posts: 1
|
Posted: Fri Oct 13, 2006 9:16 am Post subject: Re: bold text in label |
|
|
spitapps wrote:
> I am putting text in a label as a variable. But i want just the
> variable text to be bold face, so like:
>
> The variable is value of the variable blah blah.
Why don't you try using two labels instead |
|
| Back to top |
|
 |
Sneha Menon
Joined: 04 Oct 2007 Posts: 172
|
Posted: Fri Oct 13, 2006 10:44 pm Post subject: Re: bold text in label |
|
|
spitapps wrote:
> I am putting text in a label as a variable. But i want just the
> variable text to be bold face, so like:
>
> The variable is value of the variable blah blah.
----------------------------------------------------------------
Hi spitapps
I do not frequent this group, just happened to be here and saw your
posting.
Have you solved your problem? Settled on some solution??
Let me know
Sneha
--------------------------------------------------------------
|
|
| Back to top |
|
 |
|