简体   繁体   English

当用户单击所有选定的文本时,如何创建按钮必须在 c# 中的富文本框的中心对齐

[英]How can I create a button when a user click all selected text must be align on the center of rich textbox in c#

Hie, I have tried my best to create a button when a user click all selected text must be align on the center of rich textbox in c# but Am still getting what I don't want.嗨,当用户单击所有选定的文本必须在 c# 中的富文本框的中心对齐时,我已尽力创建一个按钮,但我仍然得到我不想要的东西。 So please can somebody help me please.所以请有人可以帮助我。

In your button's click event try this code:在你的按钮的点击事件中试试这个代码:

    private void button1_Click(object sender, EventArgs e)
    {
    richTextBox1.SelectionAlignment = HorizontalAlignment.Center;
    }

then you can center-align the selected part of text.然后您可以居中对齐文本的选定部分。

The image for the result I got (1)我得到的结果的图像(1)

The image for the result I got (2)我得到的结果的图像(2)

尝试

richTextBox.SelectionAlignment = HorizontalAligment.Center;

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 如何在C#的富文本框中创建换行符? - How can I create a newline in a rich textbox for C#? C#当我双击时如何选择文本框中的所有文本? - C# how can I select all the text in a textbox when I double click? 如何在WPF C#中将按钮文本对齐到中心? - How do I align button text to center in WPF C#? 如何在富文本框中更改所选的文本背景颜色wpf c# - How can I change the selected text background color in Rich text box wpf c# 如何动态创建文件并将其提供给用户(单击下载按钮)? C# - How can I dynamically create and serve a file to a user (on click of a download button)? C# 当我单击 C# Windows 表单中的按钮时,如何从来自文本框的另一个 class 中获取值? - how can I reach the value from another class coming from textbox when I click the button in C# Windows form? 如何从文本框或富文本框或 ETC 中获取“组分隔符”、0x1D 字符。 C# - How can I get a 'Group Seperator', 0x1D, character from Text box or Rich Textbox or ETC. C# 在c#/ XAML运行时动态创建(单击按钮时)如何创建TextBox的OnFocus属性? - How can I set the `OnFocus` property for a TextBox when creating them dynamically (on button click) at runtime in c#/XAML? 我如何在Form2上创建查找/搜索按钮以在C#中的Form1上的富文本框中搜索和突出显示文本 - How would I create a find/search button on form2 to search and highlight text in a rich text box on form1 in c# 如何在c#中的富文本框中更改所选文本的字体 - How do I change the font of the selected text in a rich text box in c#
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM