Drstein99 Posted October 7, 2003 Posted October 7, 2003 Any1 know how 2 increase the space between lines in a rich text box? Quote www.DRSTEIN99.com www.RAIDGEAR.net www.THERE.com -> Tell them DrStein99 sent ya!
aewarnick Posted October 7, 2003 Posted October 7, 2003 The only way I can think of is to handle KeyDown and add an extra space when e.KeyCode==(int)Keys.SpaceBar. Quote C#
pjv Posted October 8, 2003 Posted October 8, 2003 Richedit.h from the platform SDK offers these possibilities: // PARAFORMAT 2.0 masks and effects #define PFM_SPACEBEFORE 0x00000040 #define PFM_SPACEAFTER 0x00000080 #define PFM_LINESPACING 0x00000100 To use them you will need a PARAFORMAT2 struct: [structLayout( LayoutKind.Sequential )] private struct PARAFORMAT { public int cbSize; public uint dwMask; public short wNumbering; public short wReserved; public int dxStartIndent; public int dxRightIndent; public int dxOffset; public short wAlignment; public short cTabCount; [MarshalAs( UnmanagedType.ByValArray, SizeConst = 32 )] public int[] rgxTabs; // PARAFORMAT2 from here onwards public int dySpaceBefore; public int dySpaceAfter; public int dyLineSpacing; public short sStyle; public byte bLineSpacingRule; public byte bOutlineLevel; public short wShadingWeight; public short wShadingStyle; public short wNumberingStart; public short wNumberingStyle; public short wNumberingTab; public short wBorderSpace; public short wBorderWidth; public short wBorders; } You will then need SendMessage: [DllImport( "user32", CharSet = CharSet.Auto )] private static extern IntPtr SendMessage( HandleRef hWnd, int msg, int wParam, ref PARAFORMAT lParam ); Now make sure the text you want to change line spacing for is selected and do this: PARAFORMAT fmt = new PARAFORMAT(); fmt.cbSize = Marshal.SizeOf( fmt ); fmt.dwMask = PFM_LINESPACING; // Or whatever fmt.dyLineSpacing = 2; // Or whatever // This assumes you will be calling from a class derived from RichTextBox SendMessage( new HandleRef( this, Handle ), EM_SETPARAFORMAT, SCF_SELECTION, ref fmt ); Where the two constants used are: const int SCF_SELECTION = 1; const int EM_SETPARAFORMAT = 1095; Hope this helps, it's completely untested. -- Pete Quote
pjv Posted October 8, 2003 Posted October 8, 2003 Interesting.. I've just tried it and it doesn't seem to work. -- Pete Quote
paulcurtis Posted June 17, 2005 Posted June 17, 2005 Hey all, You've got to add: fmt.bLineSpacingRule = somelinespacingrule; right before the SendMessage call. This tells it what type of spacing to perform. Valid options are 0-5. For more information on the different options, check out: http://msdn.microsoft.com/library/default.asp?url=/library/en-us/shellcc/platform/commctls/richedit/richeditcontrols/richeditcontrolreference/richeditstructures/paraformat2.asp This site is the msdn article on the PARAFORMAT2 structure. I found it really helpful! ~~Paul Quote
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.