0

The default size in pixels for a tab in a RichTextBox is apparently 48 pixels, regardless of font or font size. This is set as default by .NET without me touching the SelectionTabs array. I've checked in the RTF - there's no \tx control code or anything so where the heck is this elusive '48' number stored?

I don't want to use this as a hardcoded 'magic number' in case other systems use something other than 48 pixels for a tab.

My own purpose is to help me convert from tabs to spaces (at least for fixed width fonts). But finding an answer to this also might get us closer to controlling the tab size with a single value without setting up an 'infinite' array of tab stops as implied from this answer.

Community
  • 1
  • 1
Dan W
  • 3,520
  • 7
  • 42
  • 69
  • It has a sane default that few users will object to. It is stored in a vault in Redmond, Washington State. Its value is 32 dialog template units, a pretty meaningless measure in Winforms. If you don't like surprises then the obvious thing to do is to always set it the way you think it ought to be set. If you don't like the way it only applies to the selection and doesn't permit "endless" tabs then you'll have to use SendMessage() to send EM_SETTABSTOPS – Hans Passant Apr 06 '14 at 07:40
  • Funny you should mention EM_SETTABSTOPS. I searched for that and found [this answer](http://stackoverflow.com/a/2000835/848344) which uses Win32 interop, but it cheats, and only creates 32 of them (yep, 32 "\tx"s inside the RTF!), not infinite :) I think I need to get at that vault inside Redmond... – Dan W Apr 06 '14 at 07:54
  • Read the MSDN library article for the message. One is enough to get it to repeat. – Hans Passant Apr 06 '14 at 08:06
  • Ah, just found that I originally [found](http://stackoverflow.com/a/8787004/848344) the answer to that particular chestnut anyway using the \deftab RTF control code. – Dan W Apr 06 '14 at 08:48
  • So back on topic, do you think the 48 pixel number is fixed on all systems, fonts and resolutions, unless I specify otherwise? – Dan W Apr 06 '14 at 19:41

0 Answers0