使用C#,我如何在多行文本框中设置制表位置? [英] Using C#, how do I set tab positions in a multiline textbox?

查看:315
本文介绍了使用C#,我如何在多行文本框中设置制表位置?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

有设置在C#中多行文本框自定义选项卡大小/位置的优雅的方式?

Is there a graceful way to set custom tab sizes/positions in a multiline textbox in C#?

推荐答案

您需要发送 EM_SETTABSTOPS 的消息,像这样的:

You need to send the EM_SETTABSTOPS message, like this:

static class NativeMethods {
    [DllImport("user32.dll")]
    public static extern IntPtr SendMessage(IntPtr hWnd, UInt32 Msg, IntPtr wParam, ref int lParam);
}
static void SetTabs(TextBox box) {
    //EM_SETTABSTOPS - http://msdn.microsoft.com/en-us/library/bb761663%28VS.85%29.aspx
    int lParam = 16;  //Set tab size to 4 spaces
    NativeMethods.SendMessage(box.Handle, 0x00CB, new IntPtr(1), ref lParam);
    box.Invalidate();
}

这篇关于使用C#,我如何在多行文本框中设置制表位置?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆