
正文
vb.net按钮边框 vb边框样式
提示:扫一扫查出行【扫一扫了解最新限行尾号】
复制提示
vb.net控件的BorderStyle设置为FixedSingle会出现黑线边框,可以更改他的颜色吗 比如改成红色线边框
要么重写这个控件的 OnPaint 事件,判断 BorderStyle 属性为 FixedSingle 的时候自绘其他颜色。
要么不重写,把 BorderStyle 设为 None,直接在这个控件的 Paint 事件里自绘边框,例如:
Private Sub Label1_Paint(sender As Object, e As PaintEventArgs) Handles Label1.Paint
e.Graphics.DrawRectangle(Pens.Red, New Rectangle(Label1.DisplayRectangle.X, Label1.DisplayRectangle.Y, Label1.DisplayRectangle.Width - 1, Label1.DisplayRectangle.Height - 1))
End Sub
运行效果:
相关问答
Q1: 在VB.NET中怎样改变Button按钮的边框
可以通过FlatStyle 属性来改变其边框
例如:
Button1.FlatStyle = FlatStyle.Flat
Button1.FlatStyle = FlatStyle.Popup
Q2: 在vb.net中怎么去掉按钮的边框?
asp.net 用 linkbutton
winform 用 linkLable
vb.net只是语言,跟界面没关系吧?
Q3: VB.NET怎样给字体画边框
可以利用font 设置。设置方法如下:
TextBox1.Font = New System.Drawing.Font("宋体", 10)
也可以通过字体对话框来实现 如:
Private Sub myButton_Click(sender As Object, e As EventArgs)
Dim myFontDialog As FontDialog
myFontDialog = New FontDialog()
If myFontDialog.ShowDialog() = DialogResult.OK Then
' Set the control's font.
myDateTimePicker.Font = myFontDialog.Font
End If
End Sub
Q4: 在VB.net中,Tabcontrol控件的边框怎么去掉?
你把 选项卡 拖到屏幕外面不就行了 只显示选项卡内东西 周围边缘都不要了 每个选项卡内配合labl 或按钮 标识不就行了。
Q5: 怎么用VB/VB.net/C#修改一个其他程序的窗口的边框样式?
private const int GWL_STYLE = (-16);
private const int GWL_EXSTYLE = (-20);
private const uint WS_EX_LAYERED = 0x80000;
private const uint WS_EX_TRANSPARENT = 0x20;
private const uint WS_THICKFRAME = 262144;
private const uint WS_BORDER = 8388608;
/// summary使指定 「 see cref="IntPtr"/ 句柄」 窗体 边框样式变为无边框。/summary
public static uint 无边框窗体(IntPtr 句柄) {
uint style = API_窗口.GetWindowLong(句柄, GWL_STYLE);
style = ~WS_BORDER;
style = ~WS_THICKFRAME;
return API_窗口.SetWindowLong(句柄, GWL_STYLE, style); ;
}
API窗口静态类
[DllImport("user32", EntryPoint = "SetWindowLong")]
public static extern uint SetWindowLong(IntPtr hwnd, int nIndex, uint dwNewLong);
[DllImport("user32", EntryPoint = "GetWindowLong")]
public static extern uint GetWindowLong(IntPtr hwnd, int nIndex);
修改窗口位置
/// summary
/// 设置窗体的位置和大小。
/// /summary
/// param name="hWnd"/param
/// param name="hWndInsertAfter"用于标识在z-顺序的此 CWnd 对象之前的 CWnd 对象。
/// para/para如果uFlags参数中设置了SWP_NOZORDER标记则本参数将被忽略。可为下列值之一:
/// para/paraHWND_BOTTOM:值为1,将窗体置于Z序的底部。如果参数hWnd标识了一个顶层窗体,则窗体失去顶级位置,并且被置在其他窗体的底部。
/// para/paraHWND_NOTOPMOST:值为-2,将窗体置于所有非顶层窗体之上(即在所有顶层窗体之后)。如果窗体已经是非顶层窗体则该标志不起作用。
/// para/paraHWND_TOP:值为0,将窗体置于Z序的顶部。
/// para/paraHWND_TOPMOST:值为-1,将窗体置于所有非顶层窗体之上。即使窗体未被激活窗体也将保持顶级位置。/param
/// param name="x"窗体新的x坐标。如hwnd是一个子窗体,则x用父窗体的客户区坐标表示/param
/// param name="y"窗体新的y坐标。如hwnd是一个子窗体,则y用父窗体的客户区坐标表示/param
/// param name="Width"指定新的窗体宽度/param
/// param name="Height"指定新的窗体高度/param
/// param name="wFlags"/param
/// returns/returns
[DllImport("user32.dll", CharSet = CharSet.Ansi, EntryPoint = "SetWindowPos")]
public static extern int SetWindowPos(IntPtr hWnd, hWndInsertAfter hWndInsertAfter, int x, int y, int Width, int Height, wFlags wFlags);
/// summary
/// 调整指定 「 see cref="IntPtr"/ 句柄」 窗体的位置和尺寸。
/// /summary
/// param name="句柄"指定 「 see cref="IntPtr"/ 句柄」 窗体/param
/// param name="x"横坐标/param
/// param name="y"纵坐标/param
/// param name="w"宽/param
/// param name="h"高/param
public static int 调整窗体(IntPtr 句柄, int x, int y, int w, int h) {
return API_窗口.SetWindowPos(句柄, 0, x, y, w, h, wFlags.SWP_NOZORDER);
}
/// summary
/// 调整指定 「 see cref="IntPtr"/ 句柄」 窗体的位置。
/// /summary
/// param name="句柄"指定 「 see cref="IntPtr"/ 句柄」 窗体/param
/// param name="x"横坐标/param
/// param name="y"纵坐标/param
public static int 调整窗体位置(IntPtr 句柄, int x, int y) {
return API_窗口.SetWindowPos(句柄, 0, x, y, 0, 0, wFlags.SWP_NOSIZE | wFlags.SWP_NOZORDER);
}
关于vb.net按钮边框和vb边框样式的介绍到此就结束了,不知道你从中找到你需要的信息了吗 ?如果你还想了解更多这方面的信息,记得收藏关注本站。






