|
|
|
start date: Thu, 26 Jul 2007 23:19:29 -0700,
posted on: microsoft.public.dotnet.framework.compactframework
back
| Thread Index |
|
1
unknown
|
|
2
Christian Resma Helle
|
|
3
unknown
|
|
4
unknown
|
|
5
Peter Foot [MVP]
|
Display Two Lines of Text in Button.Text
Hi all,
Is there anyone know how to display two lines of text within the
button.text?
Thanks in advance.
Date:Thu, 26 Jul 2007 23:19:29 -0700
Author:
|
Re: Display Two Lines of Text in Button.Text
I don't know if it would work, but try setting the button's multiline
property to TRUE and use a line break in your string
wrote in message
news:1185517169.165003.247740@z28g2000prd.googlegroups.com...
> Hi all,
>
> Is there anyone know how to display two lines of text within the
> button.text?
>
> Thanks in advance.
>
Date:Fri, 27 Jul 2007 09:00:19 +0200
Author:
|
Re: Display Two Lines of Text in Button.Text
I've just put together this How-To on the subject:-
http://peterfoot.net/MultilineButton.aspx
Peter
--
Peter Foot
Microsoft Device Application Development MVP
www.peterfoot.net | www.inthehand.com
In The Hand Ltd - .NET Solutions for Mobility
wrote in message
news:1185517169.165003.247740@z28g2000prd.googlegroups.com...
> Hi all,
>
> Is there anyone know how to display two lines of text within the
> button.text?
>
> Thanks in advance.
>
Date:Fri, 27 Jul 2007 10:25:15 +0100
Author:
|
Re: Display Two Lines of Text in Button.Text
Hi,
In CF you don't have multiline property on buttons. You have to use
platform invoke to set button as multiline. Below my code.
public class MultilineButton
{
private MultilineButton()
{
}
[DllImport("coredll")]
private static extern int GetWindowLong(IntPtr hWnd, int nIndex);
[DllImport("coredll")]
private static extern int SetWindowLong(IntPtr hWnd, int
nIndex, int dwNewLong);
private const int GWL_STYLE = -16;
private const int BS_CENTER = 0x00000300;
private const int BS_VCENTER = 0x00000C00;
private const int BS_MULTILINE = 0x00002000;
public static void
SetButtonAsMultiline(System.Windows.Forms.Button c)
{
c.Text = c.Text.Replace("\r\n", "\r").Replace("\n\r",
"\r").Replace("\n", "\r");
int style = GetWindowLong(c.Handle, GWL_STYLE);
SetWindowLong(c.Handle, GWL_STYLE, (style | BS_CENTER |
BS_VCENTER | BS_MULTILINE));
c.Refresh();
}
}
Call SetButtonAsMultiline and pass your button as parameter. In text
property set line break as "\n" or "\r" or "\r\n" or "\n\r" and that's it.
> I don't know if it would work, but try setting the button's multiline
> property to TRUE and use a line break in your string
>
>
> wrote in message
> news:1185517169.165003.247740@z28g2000prd.googlegroups.com...
>> Hi all,
>>
>> Is there anyone know how to display two lines of text within the
>> button.text?
>>
>> Thanks in advance.
>>
>
>
--
Best regargs,
Klaudiusz
Date:Fri, 27 Jul 2007 11:31:09 +0200
Author:
|
Re: Display Two Lines of Text in Button.Text
Hi,
In CF you don't have multiline property on buttons. You have to use
platform invoke to set button as multiline. Below my code.
public class MultilineButton
{
private MultilineButton()
{
}
[DllImport("coredll")]
private static extern int GetWindowLong(IntPtr hWnd, int nIndex);
[DllImport("coredll")]
private static extern int SetWindowLong(IntPtr hWnd, int
nIndex, int dwNewLong);
private const int GWL_STYLE = -16;
private const int BS_CENTER = 0x00000300;
private const int BS_VCENTER = 0x00000C00;
private const int BS_MULTILINE = 0x00002000;
public static void
SetButtonAsMultiline(System.Windows.Forms.Button c)
{
c.Text = c.Text.Replace("\r\n", "\r").Replace("\n\r",
"\r").Replace("\n", "\r");
int style = GetWindowLong(c.Handle, GWL_STYLE);
SetWindowLong(c.Handle, GWL_STYLE, (style | BS_CENTER |
BS_VCENTER | BS_MULTILINE));
c.Refresh();
}
}
Call SetButtonAsMultiline and pass your button as parameter. In text
property set line break as "\n" or "\r" or "\r\n" or "\n\r" and that's it.
> I don't know if it would work, but try setting the button's multiline
> property to TRUE and use a line break in your string
>
>
> wrote in message
> news:1185517169.165003.247740@z28g2000prd.googlegroups.com...
>> Hi all,
>>
>> Is there anyone know how to display two lines of text within the
>> button.text?
>>
>> Thanks in advance.
>>
>
>
--
Best regargs,
Klaudiusz
Date:Fri, 27 Jul 2007 11:31:37 +0200
Author:
|
|
|