本文介绍了如何在标签中为c#中的文本使用两种颜色的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个带文字的标签:项目 .....在本文中我需要一种颜色的专业版和另一种颜色的专业版

I have one Label with Text : Project .....In this text i need pro in one color and ject in another color

推荐答案


public partial class GradientLabel : Label {

public LabelEx() {
    InitializeComponent();
}

protected override void OnPaint(PaintEventArgs e) {
    Font font = new Font("Tahoma", 48f, FontStyle.Bold);
    LinearGradientBrush brush = new LinearGradientBrush(new Rectangle(0, 0, Width, Height + 5), Color.Gold, Color.Black, LinearGradientMode.Vertical);
    e.Graphics.DrawString(Text, font, brush, 0, 0);
}

}





这不是两种颜色,但可能会引导你解决方案。



This is not exactly "two color", but may lead you to a solution.



这篇关于如何在标签中为c#中的文本使用两种颜色的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

09-22 13:09