简体   繁体   English

如何在 C# 中更改 Windows 窗体中的系统突出显示颜色?

[英]How to change the sytem highlight color in a windows form in c#?

Is there a way to change the "default windows system blue" highlight color in all the controls in a windows form?有没有办法更改 Windows 窗体中所有控件中的“默认 Windows 系统蓝色”高亮颜色?

Including textbox, datetimepicker and all of them.包括文本框、日期时间选择器和所有这些。

Thank you.谢谢你。

Edit The highlight color is when a user select the text inside the control, normaly it's blue.编辑突出显示颜色是当用户选择控件内的文本时,通常它是蓝色的。 Can't change the system highlight color and don't want to.无法更改系统突出显示颜色并且不想更改。 I'm interested especially on 3 controls: TextBox, DateTimePicker and NumericUpDown.我特别感兴趣的是 3 个控件:TextBox、DateTimePicker 和 NumericUpDown。

By all controls I'll assume you mean all of them that would normally have a highlight color... You simply use the SelectionColor property of highlight-able controls.对于所有控件,我假设您指的是所有通常具有突出显示颜色的控件...您只需使用可突出显示控件的SelectionColor属性。

For example, it can be used like this:例如,它可以这样使用:

RichTextBox.SelectionColor = Color.Aqua;

This would set the highlight color of the RichTextBox to Aqua.这会将 RichTextBox 的突出显示颜色设置为 Aqua。 If you however wanted all controls to be highlighted... You would have to override their drawing and force them to redraw while the mouse is clicked and dragged over the area which they reside.但是,如果您希望突出显示所有控件......您将不得不覆盖它们的绘图并强制它们在单击鼠标并将其拖过它们所在的区域时重新绘制。

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

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM