文本框问题 [英] Text Box Question
问题描述
在多行文本框中重新显示文字:
是否可以在左侧或两者上留有余量
两边,所以文字没有到达边界?
非常感谢。
-
问候,
Patrick。
Re displaying text in a multi-line text box:
Is it possible to have a margin on the left hand side, or on both
sides, so the text doesn''t come right up to the border(s)?
Many thanks.
--
Regards,
Patrick.
推荐答案
是的。这应该适合你:
[DllImport(" User32.dll",EntryPoint =" SendMessage",CharSet =
CharSet.Auto) ]
private static extern int SendMessageRefRect(IntPtr hWnd,UInt32 Msg,int
wParam,ref RECT rect);
private const int EM_SETRECT = 0xB3;
public static void SetTextBoxFormatingRectangle(TextBoxBase textbox,
Rectangle rect)
{
RECT rc = new RECT(rect);
SendMessageRefRect(textbox.Handle,EM_SETRECT,0,ref rc);
}
你也可以使用EM_SETMARGINS消息,但是这并没有给你
控制顶部和底部。
Tom Clement
Apptero,Inc。
" Patrick De Ridder" < 00*@000.00>在消息中写道
news:q1 ******************************** @ 4ax.com ...
Yes it is. This should do it for you:
[DllImport("User32.dll", EntryPoint = "SendMessage", CharSet =
CharSet.Auto)]
private static extern int SendMessageRefRect(IntPtr hWnd, UInt32 Msg, int
wParam, ref RECT rect);
private const int EM_SETRECT = 0xB3;
public static void SetTextBoxFormatingRectangle(TextBoxBase textbox,
Rectangle rect)
{
RECT rc = new RECT(rect);
SendMessageRefRect(textbox.Handle, EM_SETRECT, 0, ref rc);
}
You could also use the EM_SETMARGINS message, but that doesn''t give you
control over the top and bottom.
Tom Clement
Apptero, Inc.
"Patrick De Ridder" <00*@000.00> wrote in message
news:q1********************************@4ax.com...
重新在多行文本框中显示文字:
是否可以在左侧或两侧都有边距
双方,所以文字没有到达边界?
非常感谢。
-
问候,
Patrick。
Re displaying text in a multi-line text box:
Is it possible to have a margin on the left hand side, or on both
sides, so the text doesn''t come right up to the border(s)?
Many thanks.
--
Regards,
Patrick.
" Tom Clement" <为了*********** @ Apptero.com>在消息中写道
新闻:%2 **************** @ tk2msftngp13.phx.gbl ...
"Tom Clement" <To***********@Apptero.com> wrote in message
news:%2****************@tk2msftngp13.phx.gbl...
是的是。这应该适合你:
[DllImport(" User32.dll",EntryPoint =" SendMessage",CharSet =
CharSet.Auto)]
私有静态extern int SendMessageRefRect(IntPtr hWnd,UInt32 Msg,int
wParam,ref RECT rect);
private const int EM_SETRECT = 0xB3;
public static void SetTextBoxFormatingRectangle(TextBoxBase textbox,
Rectangle rect)
{RECT rc = new RECT(rect);
SendMessageRefRect(textbox.Handle,EM_SETRECT,0,ref rc);
}
您也可以使用EM_SETMARGINS消息,但这并不能让您对顶部和底部进行控制。
Tom Clement
Apptero ,Inc。
Yes it is. This should do it for you:
[DllImport("User32.dll", EntryPoint = "SendMessage", CharSet =
CharSet.Auto)]
private static extern int SendMessageRefRect(IntPtr hWnd, UInt32 Msg, int
wParam, ref RECT rect);
private const int EM_SETRECT = 0xB3;
public static void SetTextBoxFormatingRectangle(TextBoxBase textbox,
Rectangle rect)
{
RECT rc = new RECT(rect);
SendMessageRefRect(textbox.Handle, EM_SETRECT, 0, ref rc);
}
You could also use the EM_SETMARGINS message, but that doesn''t give you
control over the top and bottom.
Tom Clement
Apptero, Inc.
非常感谢。我印象深刻!
我已经粘贴在你的代码上面#region Windows Form Designer生成了
代码
我得到了这个编译时的消息:
找不到类型或命名空间名称''RECT''(你是否错过了
使用指令或程序集引用?)
-
问候,
Patrick。
Thanks a lot. I am impressed!
I have pasted in your code above #region Windows Form Designer generated
code
and I get this message upon compilation:
The type or namespace name ''RECT'' could not be found (are you missing a
using directive or an assembly reference?)
--
Regards,
Patrick.
Darn it,I忘了包含那个定义。这是...
public struct RECT
{
public int Left;
public int Top;
public int Right;
public int Bottom;
public RECT(Rectangle rc){Left = rc 。剩下; Top = rc.Top;对=
rc.Right; Bottom = rc.Bottom; } $ / $
public RECT(int l,int t,int r,int b){Left = l;顶部= t;右= r;
底部= b; } $ / $
公共覆盖字符串ToString(){return String.Format(" RECT
({0},{1}) - ({2},{3} ),左,上,右,下); }
}
Tom Clement
Apptero,Inc。
" Patrick De Ridder < 00*@000.00>在消息中写道
news:10 *************** @ evisp-news-01.ops.asmr-01.energis-idc.net ...
Darn it, I forgot to include that definition. Here is it...
public struct RECT
{
public int Left;
public int Top;
public int Right;
public int Bottom;
public RECT(Rectangle rc) { Left = rc.Left; Top = rc.Top; Right =
rc.Right; Bottom = rc.Bottom; }
public RECT(int l, int t, int r, int b) { Left = l; Top = t; Right = r;
Bottom = b; }
public override string ToString() { return String.Format("RECT
({0},{1})-({2},{3})", Left, Top, Right, Bottom); }
}
Tom Clement
Apptero, Inc.
"Patrick De Ridder" <00*@000.00> wrote in message
news:10***************@evisp-news-01.ops.asmr-01.energis-idc.net...
" Tom Clement" <为了*********** @ Apptero.com>在消息中写道
新闻:%2 **************** @ tk2msftngp13.phx.gbl ...
"Tom Clement" <To***********@Apptero.com> wrote in message
news:%2****************@tk2msftngp13.phx.gbl...
是的。这应该适合你:
[DllImport(" User32.dll",EntryPoint =" SendMessage",CharSet =
CharSet.Auto)]
私有静态extern int SendMessageRefRect(IntPtr hWnd,UInt32 Msg,
int wParam,ref RECT rect);
private const int EM_SETRECT = 0xB3;
public static void SetTextBoxFormatingRectangle(TextBoxBase textbox,
Rectangle rect)
{RECT rc = new RECT(rect);
SendMessageRefRect(textbox.Handle,EM_SETRECT,0,ref rc);
}
您也可以使用EM_SETMARGINS消息,但这并不能让您对顶部和底部进行控制。
Tom Clement
Apptero ,Inc。
Yes it is. This should do it for you:
[DllImport("User32.dll", EntryPoint = "SendMessage", CharSet =
CharSet.Auto)]
private static extern int SendMessageRefRect(IntPtr hWnd, UInt32 Msg, int wParam, ref RECT rect);
private const int EM_SETRECT = 0xB3;
public static void SetTextBoxFormatingRectangle(TextBoxBase textbox,
Rectangle rect)
{
RECT rc = new RECT(rect);
SendMessageRefRect(textbox.Handle, EM_SETRECT, 0, ref rc);
}
You could also use the EM_SETMARGINS message, but that doesn''t give you
control over the top and bottom.
Tom Clement
Apptero, Inc.
非常感谢。我印象深刻!
我已经在你的代码上粘贴了#region Windows Form Designer生成的代码
我在编译时得到了这个消息:
类型或命名空间找不到名字''RECT''(你是否错过了
使用指令或汇编参考?)
-
问候,
Patrick。
Thanks a lot. I am impressed!
I have pasted in your code above #region Windows Form Designer generated
code
and I get this message upon compilation:
The type or namespace name ''RECT'' could not be found (are you missing a
using directive or an assembly reference?)
--
Regards,
Patrick.
这篇关于文本框问题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!