Is it possible to add padding into a Rich Text Box control between the text and the border?
I tried docking a rich text box inside of a panel, with its padding for all f
Here is a simple solution for setting the left and right margins of a RichTextBox that worked well for me in a C# Windows app. It sets both the right and left margins to 4 pixels.
[DllImport("user32.dll")]
static extern int SendMessage(IntPtr hWnd, uint wMsg, UIntPtr wParam, IntPtr lParam);
// both left and right margins set to 4 pixels with the last parm: 0x00040004
SendMessage(richtextbox1.Handle, 0xd3, (UIntPtr)0x3, (IntPtr)0x00040004);
I tried to make the SendMessage more proper below:
const int EM_SETMARGINS = 0xd3;
const int EC_LEFTMARGIN = 0x1;
const int EC_RIGHTMARGIN = 0x2;
SendMessage(richtextbox1.Handle, EM_SETMARGINS,
(UIntPtr)(EC_LEFTMARGIN | EC_RIGHTMARGIN), (IntPtr)0x00040004);
I figure this solution was not possible when the question was originally posted.