Jeff Gaines
2010-01-21 16:38:51 UTC
I want to show line numbers in a control which is derived from a WinForms
RTB control. I am using:
private void SetLineNumbers()
{
PARAFORMAT2 paraFormat = new PARAFORMAT2();
paraFormat.cbSize = (UInt32)Marshal.SizeOf(paraFormat);
// Get existing format
SendMessage(this.Handle, EM.EM_GETPARAFORMAT, 0, ref paraFormat);
// Set flags
paraFormat.dwMask = (int)(PFM.PFM_NUMBERING | PFM.PFM_NUMBERINGSTYLE |
PFM.PFM_NUMBERINGSTART);
paraFormat.wNumbering = (UInt16)NUMBERING.Arabic;
paraFormat.wNumberingStart = 0;
paraFormat.wNumberingStyle = (UInt16)NUMBERINGSTYLES.NumberOnly;
SendMessage(this.Handle, EM.EM_SETPARAFORMAT, 0, ref paraFormat);
}
It works to the extent that I do get line numbers in theleft margin but
they stop at 254. If I paste text in then 254 is just repeated for all the
higher lines, if I type lines in I just get a blank.
Is there a way round this?
I have looked at some custom RTBs on the Internet and they seem to use
lables or panels to the left of the RTB. I have alos looked at the Sharp
Edit source but that is massive overkill for what I want.
Would appreciate any guidance.
RTB control. I am using:
private void SetLineNumbers()
{
PARAFORMAT2 paraFormat = new PARAFORMAT2();
paraFormat.cbSize = (UInt32)Marshal.SizeOf(paraFormat);
// Get existing format
SendMessage(this.Handle, EM.EM_GETPARAFORMAT, 0, ref paraFormat);
// Set flags
paraFormat.dwMask = (int)(PFM.PFM_NUMBERING | PFM.PFM_NUMBERINGSTYLE |
PFM.PFM_NUMBERINGSTART);
paraFormat.wNumbering = (UInt16)NUMBERING.Arabic;
paraFormat.wNumberingStart = 0;
paraFormat.wNumberingStyle = (UInt16)NUMBERINGSTYLES.NumberOnly;
SendMessage(this.Handle, EM.EM_SETPARAFORMAT, 0, ref paraFormat);
}
It works to the extent that I do get line numbers in theleft margin but
they stop at 254. If I paste text in then 254 is just repeated for all the
higher lines, if I type lines in I just get a blank.
Is there a way round this?
I have looked at some custom RTBs on the Internet and they seem to use
lables or panels to the left of the RTB. I have alos looked at the Sharp
Edit source but that is massive overkill for what I want.
Would appreciate any guidance.
--
Jeff Gaines Dorset UK
The facts, although interesting, are irrelevant
Jeff Gaines Dorset UK
The facts, although interesting, are irrelevant