问题描述
我正在尝试制作我的第一个自定义控件。我想要做的就是在进度条上的文本中显示一个值。我添加了我需要的属性(TextValue& TextForeColor),但是如何在进度条上显示实际文本?这就是我到目前为止:
Imports System.ComponentModel
Public Class MeterBar
继承ProgressBar
公共属性TextValue()As String
获取
返回MyBase.Text
结束获取
设置(ByVal值为字符串)
MyBase.Text = Value
结束集
结束属性
公共属性TextForeColor()As Color
获取
返回MyBase.ForeColor
结束获取
设置(ByVal值为颜色)
MyBase.ForeColor =价值
结束套件
结束物业
- 我可以显示文字w / o从文本框继承?另外,如何在进度条中设置文本的对齐方式(左/中/右)?请帮忙。
Hi, I am trying to make my first custom control. All I want to do is display a value in Text on a progressbar. I''ve added the properties that I need (TextValue & TextForeColor), but how do I display the actual text on the progressbar? This is what I have so far:
Imports System.ComponentModel
Public Class MeterBar
Inherits ProgressBar
Public Property TextValue() As String
Get
Return MyBase.Text
End Get
Set(ByVal Value As String)
MyBase.Text = Value
End Set
End Property
Public Property TextForeColor() As Color
Get
Return MyBase.ForeColor
End Get
Set(ByVal Value As Color)
MyBase.ForeColor = Value
End Set
End Property
-Can I display text w/o inheriting from textbox? Also, how could I set the alignment of the text w/in the progressbar (Left/Center/Right)? Please help.
推荐答案
这篇关于如何将文本添加到自定义控件?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!