有什么方法可以更改 .NET RichTextBox 中的默认选项卡大小?它目前似乎设置为相当于 8 个空格,这对我来说有点大.
Is there any way to change the default tab size in a .NET RichTextBox? It currently seems to be set to the equivalent of 8 spaces which is kinda large for my taste.
为了澄清,我想将 "的全局默认设置为控件的 4 个空格.据我了解, SelectionTabs 属性要求您首先选择所有文本,然后通过数组选择选项卡宽度.如果必须,我会这样做,但如果可能的话,我宁愿只更改一次全局默认值,这样我就不必每次都这样做.
To clarify, I want to set the global default of " " displays as 4 spaces for the control. From what I can understand, the SelectionTabs property requires you to select all the text first and then the the tab widths via the array. I will do this if I have to, but I would rather just change the global default once, if possible, sot that I don't have to do that every time.
您可以通过设置 SelectionTabs 属性.
You can set it by setting the SelectionTabs property.
private void Form1_Load(object sender, EventArgs e)
{
richTextBox1.SelectionTabs = new int[] { 100, 200, 300, 400 };
}
更新:
顺序很重要....
UPDATE:
The sequence matters....
如果您在初始化控件文本之前设置了选项卡,那么您不必在设置选项卡之前选择文本.
If you set the tabs prior to the control's text being initialized, then you don't have to select the text prior to setting the tabs.
例如,在上面的代码中,这将保留带有原始 8 个空格制表位的文本:
For example, in the above code, this will keep the text with the original 8 spaces tab stops:
richTextBox1.Text = " 1 2 3 4";
richTextBox1.SelectionTabs = new int[] { 100, 200, 300, 400 };
但这将使用新的:
richTextBox1.SelectionTabs = new int[] { 100, 200, 300, 400 };
richTextBox1.Text = " 1 2 3 4";
这篇关于修改 RichTextBox 中的默认选项卡大小的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持html5模板网!
单击带有 JAvascript.ASP.NET C# 的超链接时删除目录Deleting a directory when clicked on a hyperlink with JAvascript.ASP.NET C#(单击带有 JAvascript.ASP.NET C# 的超链接时删除目录)
asp.net listview 在单击时突出显示行asp.net listview highlight row on click(asp.net listview 在单击时突出显示行)
从函数调用按钮 OnClickCalling A Button OnClick from a function(从函数调用按钮 OnClick)
ASP.net C# Gridview ButtonField onclick 事件ASP.net C# Gridview ButtonField onclick event(ASP.net C# Gridview ButtonField onclick 事件)
将 OnClick 事件添加到 ASP.NET 控件Adding OnClick event to ASP.NET control(将 OnClick 事件添加到 ASP.NET 控件)
多个提交按钮点击问题?Multiple submit Button click problem?(多个提交按钮点击问题?)