[Closed] system.windows.forms.textBox tab spacing?
Can any one see a way to set the number of spaces in a tab character for a textBox? Looks like it is about 5 or 6 right now and I want 2 or 3.
Here is a site explaining it in VB but not quite sure how to get this to work in Max Script
http://www.devx.com/vb2themax/Tip/18611
Can any one convert it for me. I鈥檒l keep looking for a C# example as I understand that far better.
The RichTextBox class has a selectionTabs property that 鈥淕ets or sets the absolute tab stop positions in a RichTextBox control.鈥?/p>
Maybe that would help?
Good point Marco, I鈥檒l have a look at that. I don鈥檛 need anything fancy and really just want it displaying information that has been formated already.
Denis, I need to learn that stuff my self I guess. If the Rich editor is no good then I will try that solution out.
Thanks both of you.
as usually if i can鈥檛 do anything using mxs i do it with c#
fn getTabStopClass =
(
source = ""
source += "using System;
"
source += "using System.Runtime.InteropServices;
"
source += "using System.Windows.Forms;
"
source += "class TabStops
"
source += "{
"
source += " private const int EM_SETTABSTOPS = 0x00CB;
"
source += " [DllImport(\"User32.dll\", CharSet = CharSet.Auto)]
"
source += " public static extern IntPtr SendMessage(IntPtr h, int msg, int wParam, int[] lParam);
"
source += " public static void SetTextBoxTabWidth(TextBox textbox, int tabWidth)
"
source += " {
"
source += " int[] stops = new int[] { tabWidth };
"
source += " SendMessage(textbox.Handle, EM_SETTABSTOPS, 1, stops);
"
source += " }
"
source += "}
"
-- Compile on fly
csharpProvider = dotnetobject "Microsoft.CSharp.CSharpCodeProvider"
compilerParams = dotnetobject "System.CodeDom.Compiler.CompilerParameters"
compilerParams.ReferencedAssemblies.Add("System.dll");
compilerParams.ReferencedAssemblies.Add("System.Windows.Forms.dll");
compilerParams.GenerateInMemory = on
compilerResults = csharpProvider.CompileAssemblyFromSource compilerParams #(source)
output = compilerResults.CompiledAssembly.CreateInstance "TabStops"
)
tabstopclass = getTabStopClass()
/*
using:
tabstopclass.SetTextBoxTabWidth <textbox> <tabwidth in dialog template units>
tabstopclass.SetTextBoxTabWidth mytbox 10
*/
for dialog box units check:
http://msdn.microsoft.com/en-us/library/ms645475(VS.85).aspx
RichTextBox is the solution. In all my new tools I use rich text instead of text box.
but my c# code is very easy to change to support ListView tab width, or combobox for example.
Denis gets the prize. I couldn鈥檛 get the selectionTabs property to do anything at all. And I couldn鈥檛 find any decent examples again on how it is supposed to work. Not much about it at MSDN either.
Thanks Denis.