C#在选择文本时启用按钮 [英] c# enable a button when text is selected
本文介绍了C#在选择文本时启用按钮的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我想做的是当我在richtextbox中输入文本时禁用2按钮,但是当我突出显示txt时,按钮启用.
到目前为止,这里是我的代码
if (txtDisplay.Modified == true) { cutText.Enabled = false; copyText.Enabled = false; }
希望有人可以提供帮助
解决方案
假设突出显示"是指您已选择文本:私有 布尔 IsSelection = false ; 私有 无效 richTextBox1_SelectionChanged(对象发件人,EventArgs e) { IsSelection = richTextBox1.SelectionLength!= 0 ; button1.Enabled = IsSelection; button2.Enabled = IsSelection; }
突出显示的意思是用户突出显示文本.
what i want to do is disable 2 button when i enter text in the richtextbox but when i highlight the txt the button enable.
here my code so far
if (txtDisplay.Modified == true) { cutText.Enabled = false; copyText.Enabled = false; }
hope someone can help
解决方案
Assuming by "highlight" you mean you have selected text:private bool IsSelection = false; private void richTextBox1_SelectionChanged(object sender, EventArgs e) { IsSelection = richTextBox1.SelectionLength != 0; button1.Enabled = IsSelection; button2.Enabled = IsSelection; }
what i mean by highlight is the user highlights the text.
anyone this bit is really annoying me as only part i got a problem with
这篇关于C#在选择文本时启用按钮的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文