vb.net - How to change border color of a textbox that is inside a groupbox (if possible, through a button)
问题描述
I'm trying to make the text box inside a group box to change border color when it is empty. Example below.
But when I did it in group box, it only works when the form loads but the color won't change..
The code:
Private Sub Groupbox1_Paint(sender As Object, e As PaintEventArgs) Handles GroupBox1.Paint
With TextBox1
Dim p As New Pen(If(TextBox1.Text <> "", Color.White, Color.Red), 0)
e.Graphics.DrawRectangle(p, .Left - 1, .Top - 1, .Width + 1, .Height + 1)
p.Dispose()
End With
End Sub
REFERENCE
https://www.youtube.com/watch?v=yRL4VqebXoU
https://visualstudiocodes.blogspot.com/2019/10/text-box-border-largest-vbnet-when.html
解决方案
推荐阅读
- keras - (keras)我想在 val_acc 停止改进时衰减学习率
- java - Spring Boot 和 PostgreSQL-HikariCP 总是返回 null
- jpa - eclipselink:从 org.eclipse.persistence.internal.jpa.EntityManagerImpl.lock 抛出 NullPointerException
- gulp - 为“您是否忘记发出异步完成信号?”而苦苦挣扎?
- r - 如何获取最后一个逗号后的文本?
- matlab - 如何使用逆离散小波变换融合彩色图像?
- jquery - Jquery 无法识别从数组传递的选择器
- javascript - 为唯一项目反应路由器 url 路径
- if-statement - 如何使用 MicroStrategy Visual Insights 中的 Case/If 函数将具有数值的属性转换为文本值?
- bash - JQ query on JSON file