十年网站开发经验 + 多家企业客户 + 靠谱的建站团队
量身定制 + 运营维护+专业推广+无忧售后,网站问题一站解决
也容易,如果是黑白三个颜色加上相同的渐变量,彩色的是起始颜色的三个分量与终止颜色的对应三个分量的差值,再除于相同的份数,就得出三原色各自的步进量。
清河网站制作公司哪家好,找创新互联建站!从网页设计、网站建设、微信开发、APP开发、成都响应式网站建设公司等网站项目制作,到程序开发,运营维护。创新互联建站成立于2013年到现在10年的时间,我们拥有了丰富的建站经验和运维经验,来保证我们的工作的顺利进行。专注于网站建设就选创新互联建站。
窗体上放个图片框试试下面代码:
Private Sub PictureBox1_Paint(ByVal sender As Object, ByVal e As System.Windows.Forms.PaintEventArgs) Handles PictureBox1.Paint
Dim startColor As Color = Color.Red
Dim endColor As Color = Color.Green
Dim s As String = "vb.net 如何使文字能渐变颜色,就是颜色慢慢变淡然后在慢慢恢复?"
Dim Steps As Integer = s.Length \ 2
Dim StepR As Integer = (CInt(endColor.R) - startColor.R) \ Steps
Dim StepG As Integer = (CInt(endColor.G) - startColor.G) \ Steps
Dim StepB As Integer = (CInt(endColor.B) - startColor.B) \ Steps
Dim R As Integer = startColor.R
Dim G As Integer = startColor.G
Dim B As Integer = startColor.B
Dim drawFont As New System.Drawing.Font("Arial", 16)
Dim X As Integer = 50
For i As Integer = 1 To Steps
Dim drawBrush As New SolidBrush(Color.FromArgb(R, G, B))
e.Graphics.DrawString(s.Substring(i - 1, 1), drawFont, drawBrush, X, 50.0)
X += 18
R += StepR
G += StepG
B += StepB
Next
For i As Integer = 1 To Steps
Dim drawBrush As New SolidBrush(Color.FromArgb(R, G, B))
e.Graphics.DrawString(s.Substring(i + Steps - 1, 1), drawFont, drawBrush, X, 50.0)
X += 18
R -= StepR
G -= StepG
B -= StepB
Next
End Sub
复杂的不会,来点儿简单的,借用在listbox里按下鼠标时再移动,会高亮显示选择行,并且会随鼠标移动而变化的这一特点改进的,不足之处是在listbox里,此时处于鼠标左键在按下状态。
Declare Sub mouse_event Lib "user32" (ByVal dwFlags As Long, ByVal dx As Long, ByVal dy As Long, ByVal cButtons As Long, ByVal dwExtraInfo As Long)
Public Const MOUSEEVENTF_LEFTDOWN = H2 '模拟鼠标左键按下
Private Sub ListBox1_MouseMove(sender As Object, e As MouseEventArgs) Handles ListBox1.MouseMove
mouse_event(MOUSEEVENTF_LEFTDOWN, 0, 0, 0, 0)
End Sub
首先,设定Timer控件的Enabled属性为True,Interval属性为1000(单位为毫秒)。
然后,添加程序代码如下:
private void timer1_Tick(object sender, EventArgs e)
{
if (this.label1.BackColor == Color.Red) //判断当前背景色是否为红色
this.label1.BackColor = Color.Blue; //如果是则变为蓝色
else //如果当前背景色不是红色
this.label1.BackColor = Color.Red; //将背景色变为红色
}
我是新手,仅谈谈我的理解,按钮的MouseEnter与MouseLeave事件就可以解决,需要这么复杂吗?
比如当鼠标移入按钮(Button1)时,按钮的字体变色(假如变为红色)可以写为(MouseEnter事件):
Button1.Forecolor=color.red;
当鼠标移出,字体颜色变回去(假如本来是黄色)(MouseLeave事件):
Button1.Forecolor=color.yellow;
如要做高级的动态变化,估计添加timer进来,写Timer的Tick事件,比如Tmier每Tick一次,按钮的红色就加5,同时设置按钮的Tick间距。
应该是隔一行换颜色。
Me.DataGridView1.AlternatingRowsDefaultCellStyle.BackColor = Color.Red
使用该代码即可。