我想在Compact Framework中创建一个两行文本按钮。我已经尝试了这个帖子中的每个想法,但没有成功。
http://social.msdn.microsoft.com/forums/en-US/winforms/thread/626c21e0-369f-441e-b2f1-b51db633e38b
如果我使用\n
或\r\n
或Environment.NewLine
,会出现方块。
我正在使用Compact Framework 3.5。
有没有办法制作一个两行文本框?
我想在Compact Framework中创建一个两行文本按钮。我已经尝试了这个帖子中的每个想法,但没有成功。
http://social.msdn.microsoft.com/forums/en-US/winforms/thread/626c21e0-369f-441e-b2f1-b51db633e38b
如果我使用\n
或\r\n
或Environment.NewLine
,会出现方块。
我正在使用Compact Framework 3.5。
有没有办法制作一个两行文本框?
您需要将按钮设置为允许多行。可以通过以下P / Invoke代码实现。
private const int BS_MULTILINE = 0x00002000;
private const int GWL_STYLE = -16;
[System.Runtime.InteropServices.DllImport("coredll")]
private static extern int GetWindowLong(IntPtr hWnd, int nIndex);
[System.Runtime.InteropServices.DllImport("coredll")]
private static extern int SetWindowLong(IntPtr hWnd, int nIndex, int dwNewLong);
public static void MakeButtonMultiline(Button b)
{
IntPtr hwnd = b.Handle;
int currentStyle = GetWindowLong(hwnd, GWL_STYLE);
int newStyle = SetWindowLong(hwnd, GWL_STYLE, currentStyle | BS_MULTILINE);
}
使用方式如下:
MakeButtonMultiline(button1);
(来源,已验证在CE设备上可用)