vb.net颜色设置 VB窗体背景颜色设置程序怎么写

VB.NET中关于DataGrid颜色的自定义

近来项目用到了一个类似WEB控件DataGrid中自定义行或列的颜色的功能 然而应用却是在WIN的窗体下 实现起来无法使用类似JavaScript的脚本注册的功能来动态完成 十分着急 察看了CSDN的一些关于WinForm下的关于DataGrid的资料 看到这样的一篇介绍DG结构的美文 题目是《Henry手记:WinForm Datagrid结构剖析》 作者是韩睿(Latitude) 其中介绍了WIN DG的颜色的定义 但是主要是针对每一个Cell的      我们需要的则是标记某一行的数据 用颜色突出显示 所以作了部分改动 现在把部分代码张贴出来供大家参考       . 基础类出自韩睿      URL: ?id=       Public Class DataGridColoredTextBoxColumn    Inherits DataGridTextBoxColumn    Public rowcollection As New Collection()    Public BackColor() As Color    Public ForeColor() As Color    Private Function GetText(ByVal Value As Object) As String       If TypeOf (Value) Is System DBNull Then       Return NullText       ElseIf Value Is Nothing Then       Return       Else       Return Value ToString       End If       End Function    Protected Overloads Overrides Sub Paint(ByVal g As System Drawing Graphics ByVal bounds As System Drawing Rectangle _       ByVal source As System Windows Forms CurrencyManager _       ByVal rowNum As Integer _       ByVal backBrush As System Drawing Brush _       ByVal foreBrush As System Drawing Brush _       ByVal alignToRight As Boolean)    Dim text As String

创新互联公司业务包括:成品网站、企业产品展示型网站建设、成都品牌网站建设、电子商务型网站建设、成都外贸网站建设公司(多语言)、商城系统网站开发、按需定制、营销型网站建设等。效率优先,品质保证,用心服务是我们的核心价值观,我们将继续以良好的信誉为基础,秉承稳固与发展、求实与创新的精神,为客户提供更全面、更优质的互联网服务!

text = GetText(GetColumnValueAtRow(source rowNum))    backBrush = New SolidBrush(TextBox BackColor)    foreBrush = New SolidBrush(TextBox ForeColor)

ReDim Preserve BackColor(rowcollection Count)    ReDim Preserve ForeColor(rowcollection Count)    Dim i As Integer =     Do While (i = rowcollection Count)    If rowNum = Val(rowcollection Item(i)) Then

If Not BackColor(i ) IsEmpty Then    backBrush = New SolidBrush(BackColor(i ))    End If    If Not ForeColor(i ) IsEmpty Then    foreBrush = New SolidBrush(ForeColor(i ))    End If    End If       i +=     Loop      MyBase PaintText(g bounds text backBrush foreBrush alignToRight)       End Sub       End Class       关于行颜色定义的类      Imports System Windows Forms      Namespace Truck_WEB       Public Class DrawDGClass       Public Class ReDrawDataDridControls : Inherits DataGridColoredTextBoxColumn       Public Sub DrawCorol(ByRef DG As DataGrid Optional ByVal CurrentRowindex As Integer = )       设置选中的行的颜色 默认是第一行选中       Dim dt As DataTable       Dim ts As New DataGridTableStyle()       ts AllowSorting = False       Dim aColumnTextColumn As DataGridColoredTextBoxColumn       dt = CType(DG DataSource DataTable)       ts MappingName = CType(DG DataSource DataTable) TableName       DG TableStyles Clear()       Dim numCols As Integer       numCols = dt Columns Count       Dim i j As Integer       i =       j =

lishixinzhi/Article/program/net/201311/12321

VB.NET设置屏幕分辨率、颜色位数、刷新率 实例代码

这篇文章介绍了VB.NET设置屏幕分辨率、颜色位数、刷新率

实例代码,有需要的朋友可以参考一下

复制代码

代码如下:

Private

Declare

Function

GetDeviceCaps

Lib

"gdi32"

(ByVal

hdc

As

Long,

ByVal

nIndex

As

Long)

As

Long

Private

Declare

Function

ChangeDisplaySettings

Lib

"user32"

Alias

"ChangeDisplaySettingsA"

(lpDevMode

As

Any,

ByVal

dwflags

As

Long)

As

Long

Private

Const

CCDEVICENAME

As

Long

=

32

Private

Const

CCFORMNAME

As

Long

=

32

Private

Const

DM_BITSPERPEL

As

Long

=

H40000

Private

Const

DM_PELSWIDTH

As

Long

=

H80000

Private

Const

DM_PELSHEIGHT

As

Long

=

H100000

Private

Const

DM_DISPLAYFLAGS

As

Long

=

H200000

Private

Const

DM_DISPLAYFREQUENCY

=

H400000

Private

Const

CDS_FORCE

As

Long

=

H80000000

Private

Const

BITSPIXEL

As

Long

=

12

Private

Const

HORZRES

As

Long

=

8

Private

Const

VERTRES

As

Long

=

10

Private

Const

VREFRESH

=

116

Private

Type

DEVMODE

dmDeviceName

As

String

*

CCDEVICENAME

dmSpecVersion

As

Integer

dmDriverVersion

As

Integer

dmSize

As

Integer

dmDriverExtra

As

Integer

dmFields

As

Long

dmOrientation

As

Integer

dmPaperSize

As

Integer

dmPaperLength

As

Integer

dmPaperWidth

As

Integer

dmScale

As

Integer

dmCopies

As

Integer

dmDefaultSource

As

Integer

dmPrintQuality

As

Integer

dmColor

As

Integer

dmDuplex

As

Integer

dmYResolution

As

Integer

dmTTOption

As

Integer

dmCollate

As

Integer

dmFormName

As

String

*

CCFORMNAME

dmUnusedPadding

As

Integer

dmBitsPerPel

As

Integer

dmPelsWidth

As

Long

dmPelsHeight

As

Long

dmDisplayFlags

As

Long

dmDisplayFrequency

As

Long

End

Type

Private

Sub

cmdChangeDesktopMode_Click()

Dim

DM

As

DEVMODE

With

DM

.dmPelsWidth

=

CInt(txtNewWidth.Text)

.dmPelsHeight

=

CInt(txtNewHeight.Text)

.dmBitsPerPel

=

CInt(txtNewColor.Text)

.dmDisplayFrequency

=

CInt(txtNewFreq.Text)

.dmFields

=

DM_PELSWIDTH

Or

DM_PELSHEIGHT

Or

DM_BITSPERPEL

Or

DM_DISPLAYFREQUENCY

.dmSize

=

LenB(DM)

End

With

If

ChangeDisplaySettings(DM,

CDS_FORCE)

Then

MsgBox

"错误!不支持此模式!"

End

If

End

Sub

Private

Sub

Form_Load()

txtOldWidth.Text

=

GetDeviceCaps(Me.hdc,

HORZRES)

txtOldHeight.Text

=

GetDeviceCaps(Me.hdc,

VERTRES)

txtOldColor.Text

=

GetDeviceCaps(Me.hdc,

BITSPIXEL)

txtOldFreq.Text

=

GetDeviceCaps(Me.hdc,

VREFRESH)

End

Sub

VB。net如何设置按钮不可控时的字体颜色

首先command的style要设为1,否则无法改变

然后在backcolor设置颜色

按钮的字体颜色不能改

如果想改字体颜色,简单点可以用image做按钮。

如果一定要,请看:

在工程中添加以下模块(Module):

Module modExtButton.bas

Option Explicit


网页名称:vb.net颜色设置 VB窗体背景颜色设置程序怎么写
转载来源:http://bzwzjz.com/article/hhpdhi.html

其他资讯

Copyright © 2007-2020 广东宝晨空调科技有限公司 All Rights Reserved 粤ICP备2022107769号
友情链接: 成都企业网站制作 重庆电商网站建设 成都网站设计公司 成都响应式网站建设 成都网站设计 成都网站建设 成都响应式网站建设 成都定制网站建设 高端网站设计 公司网站建设 企业网站制作 网站建设 成都网站制作 网站制作 企业手机网站建设 成都网站建设公司 企业网站建设公司 网站设计制作 成都网站制作 网站制作 成都营销网站建设 网站建设开发