关于vb.net浅灰的信息

VB MSFlexGrid1.TextMatrix(i, 3)

'MSFlexGrid赋值的方法 MSFlexGrid1.TextMatrix(0, 1) = "老师"

创新互联是一家专业提供沁县企业网站建设,专注与成都网站设计、成都做网站、H5高端网站建设、小程序制作等业务。10年已为沁县众多企业、政府机构等服务。创新互联专业网站建设公司优惠进行中。

MSFlexGrid1.TextMatrix(1, 2) = "学生"

MSFlexGrid1.TextMatrix(2, 3) = "校长"

MSFlexGrid1.TextMatrix(3, 4) = "班主任"

MSFlexGrid1.TextMatrix(4, 5) = "教务主任"

MSFlexGrid1.AddItem 2

MSFlexGrid1.AddItem 4

MSFlexGrid1.AddItem 6

MSFlexGrid1.AddItem 8

``MSFLEXGRID 中如何取的某个单元格的数据

Private Sub MSFlexGrid1_Click()

MsgBox MSFlexGrid1.TextMatrix(MSFlexGrid1.Row, MSFlexGrid1.Col), vbOKOnly, "提示消息"

End Sub

MSFlexGrid1.Row,表格中的当前行

MSFlexGrid1.Col,表格中的当前列

'初始化MSFlexGrid

Dim i As Integer

MSFlexGrid1.Rows = 0

For i = 0 To 10

MSFlexGrid1.AddItem "AA" + Str(i)

'For i = 0 To 10

MSFlexGrid1.Col = 1

MSFlexGrid1.Row = i

MSFlexGrid1.Text = CStr(i)

MSFlexGrid1.Col = 2

MSFlexGrid1.Row = i

MSFlexGrid1.Text = CStr(i) CStr(i)

MSFlexGrid1.Col = 3

MSFlexGrid1.Row = i

MSFlexGrid1.Text = CStr(i) CStr(i) CStr(i)

Next i'实现MSFlexGrid控件,单行背景为浅灰,双行为兰色

Dim j As Integer

With MSFlexGrid1

.AllowBigSelection = True ' 设置网格样式

.FillStyle = flexFillRepeat

For j = 0 To .Rows - 1

.Row = j: .Col = .FixedCols

.ColSel = .Cols() - .FixedCols - 1

If j Mod 2 = 0 Then

.CellBackColor = HC0C0C0 ' 浅灰

Else

.CellBackColor = vbBlue ' 兰色

End If

Next j

End With '在MsFlexGrid控件单元格中插入背景图形

Set MSFlexGrid1.CellPicture = LoadPicture("f:\temp\snow.bmp")'MSFlexGrid控件如何移到最后一行

MSFlexGrid1.TopRow = MSFlexGrid1.Rows - 1

'隐藏第一行

'Private Sub Command1_Click1()

'MSFlexGrid1.RowHeight(1) = 0

'End Sub

'隐藏第一列

'Private Sub Command_Click2()

'MSFlexGrid1.ColWidth(1) = 0

'End Sub

在MSFlexGrid上点击右键,选择属性,选择"选择模式",自己任选

点击得到行代码

msgrid1.Col就是你选择的列号

msgrid1.Row 就是你选择的行号

msgrid1.text就是你选择单元格的内容。

将文本赋值给MsFlexGrid的单元格

MsFlexGrid.TextMatrix(3,1)=”Hello”

在MsFlexGrid控件单元格中插入背景图形

Set MsFlexGrid.CellPicture=LoadPicture(“C:\temp\1.bmp”)

选中某个单元

MsFlexGrid.Row=1

MsFlexGrid.Col=1

用粗体格式化当前选中单元

MsFlexGrid.CellFontBold=True

添加新的一行

使用AddItem方法,用Tab字符分开不同单元格的内容

dim row as string

row=”AAA”vbtab”bbb”

MsFlexFrid1.addItem row

怎样来实现MSFlexGrid控件单数行背景为白色,双数的行背景为蓝色?

Dim i As Integer

With MSFlexGrid1

.AllowBigSelection = True ’ 设置网格样式

.FillStyle = flexFillRepeat

For i = 0 To .Rows - 1

.Row = i: .Col = .FixedCols

.ColSel = .Cols() - .FixedCols - 1

If i Mod 2 = 0 Then

.CellBackColor = HC0C0C0 ’ 浅灰

Else

.CellBackColor = vbBlue ’ 兰色

End If

Next i

End With

MSFlexGrid控件如何移到最后一行

MSFlexGrid1.TopRow = MSFlexGrid1.Rows – 1

如何判断msflexgrid有无滚动条

Declare Function GetScrollRange Lib "user32" (ByVal hWnd As Long, ByVal nBar As Long, lpMinPos As Long, lpMaxPos As Long) As Long

Public Const SB_HORZ = H0

Public Const SB_VERT = H1

Public Function VsScroll(MshGrid As MSHFlexGrid) As Boolean ’判断水平滚动条的可见性

Dim i As Long

VsScroll = False

i = GetScrollRange(MshGrid.hWnd, SB_HORZ, lpMinPos, lpMaxPos)

If lpMaxPos lpMinPos Then VsScroll = True

End Function

Public Function HeScroll(MshGrid As MSHFlexGrid) As Boolean ’判断垂直滚动条的可见性

Dim i As Long

HeScroll = False

i = GetScrollRange(MshGrid.hWnd, SB_VERT, lpMinPos, lpMaxPos)

If lpMaxPos lpMinPos Then HeScroll = True

End Function

程序运行时,想动态增加MSFlexgrid的列数

在第2列后插入一列:

Private Sub Form_Load()

Me.MSHFlexGrid1.Cols = 5

MSHFlexGrid1.Rows = 2

For i = 0 To Me.MSHFlexGrid1.Cols - 1

Me.MSHFlexGrid1.TextMatrix(0, i) = i

Me.MSHFlexGrid1.TextMatrix(1, i) = i

Next

End Sub

Private Sub Command1_Click()

Me.MSHFlexGrid1.Cols = Me.MSHFlexGrid1.Cols + 1

Me.MSHFlexGrid1.ColPosition(5) = 3

End Sub

请教MSFlexGrid中的对齐功能的使用

设置MSFlexGrid1.ColAlignment(index)=n

得到MSFlexGrid控件中当前选中的一行

msflexgrid1.rowsel就是当前选中行

如何通过代码调节列宽度

msflexgrid1.colwidth(i)=4000

--------------------------------------------------------------------------------------

'OutDataToText

'将MsFlexGrid控件中显示的内容输出到文本文件

Public Sub OutDataToText(Flex As MSFlexGrid)

Dim s As String

Dim i As Integer

Dim j As Integer

Dim k As Integer

Dim strTemp As String

On Error GoTo Ert

Me.MousePointer = 11

On Error Resume Next

DoEvents

Dim FileNum As Integer

FileNum = FreeFile

Open "d:aa.txt" For Output As #FileNum

With Flex

k = .Rows

For i = 0 To k - 1

strTemp = ""

For j = 0 To .Cols - 1

DoEvents

strTemp = strTemp .TextMatrix(i, j) ","

Next j

Print #FileNum, Left(strTemp, Len(strTemp) - 1)

Next i

End With

Close #FileNum

Me.MousePointer = 0

MsgBox "导出成功"

Ert:

MsgBox Err.Description

Me.MousePointer = 0

End Sub

增加 MsFlexGrid 的编辑功能

概述

MsFlexGrid 控件没有提供文本编辑的功能,下面的例子演示了如何利用一个TextBox 实现编辑当前网格的功能。

在按下一个键后, 就把TextBox 移动到当前的位置, 并激活。 在键入回车或移动到其他网格时,

就把TextBox 中的内容放到网格中。

实现步骤

1 打开 VB5, 开启一个新的工程。

2 在菜单“工程” 中选择 “部件”, 在列表中选中 “Microsoft FlexGrid Control ..”

3 放一个 MsFlexGrid 控件和一个TextBox 控件(Text1)到 Form1。 修改MsFlexGrid 控件的名称为 Grid1,

设置Grid1 的行,列 为 4, 固定行,列为 0。 设置 Text1 的 Visiable 为 False, BorderStyle 为

None(0)。

4 在Form1 的代码中增加声明:

Const ASC_ENTER = 13 '回车

Dim gRow As Integer

Dim gCol As Integer

5 增加代码到 Grid_KeyPress 过程:

Private Sub Grid1_KeyPress(KeyAscii As Integer)

' Move the text box to the current grid cell:

Text1.Top = Grid1.CellTop + Grid1.Top

Text1.Left = Grid1.CellLeft + Grid1.Left

' Save the position of the grids Row and Col for later:

gRow = Grid1.Row

gCol = Grid1.Col

' Make text box same size as current grid cell:

Text1.Width = Grid1.CellWidth - 2 * Screen.TwipsPerPixelX

Text1.Height = Grid1.CellHeight - 2 * Screen.TwipsPerPixelY

' Transfer the grid cell text:

Text1.Text = Grid1.Text

' Show the text box:

Text1.Visible = True

Text1.ZOrder 0 ' 把 Text1 放到最前面!

Text1.SetFocus

' Redirect this KeyPress event to the text box:

If KeyAscii ASC_ENTER Then

SendKeys Chr$(KeyAscii)

End If

End Sub

6 增加代码到 Text1_KeyPress 过程:

Private Sub Text1_KeyPress(KeyAscii As Integer)

If KeyAscii = ASC_ENTER Then

Grid1.SetFocus ' Set focus back to grid, see Text_LostFocus.

KeyAscii = 0 ' Ignore this KeyPress.

End If

End Sub

7 增加代码到 Text1_LostFocus 过程:

Private Sub Text1_LostFocus()

Dim tmpRow As Integer

Dim tmpCol As Integer

' Save current settings of Grid Row and col. This is needed only if

' the focus is set somewhere else in the Grid.

tmpRow = Grid1.Row

tmpCol = Grid1.Col

' Set Row and Col back to what they were before Text1_LostFocus:

Grid1.Row = gRow

Grid1.Col = gCol

Grid1.Text = Text1.Text ' Transfer text back to grid.

Text1.SelStart = 0 ' Return caret to beginning.

Text1.Visible = False ' Disable text box.

' Return row and Col contents:

Grid1.Row = tmpRow

Grid1.Col = tmpCol

End Sub

8 好了。 按 F5 开始测试。 您可以自由地在 Grid 中移动, 按回车可以开始或结束编辑。

使用MsFlexGrid控件的几个函数

作者:中国论坛网收集 来源: 加入时间:2004-8-25

在VB处理数据显示的时候,使用表格是一种好的方法,虽然DataGrid可以与数据源绑定,但是总有美中不足,就是

外观不好看,所以有时应用MsFlexGrid显示数据还是一种比较好的方法,以下几个函数是用来控制MsFlexGrid的程序

(本人语言表达能力有限,还请见谅)

''MsFlexGrid操作函数

''合并列

Public Function MergeCol(GridObj As Object, ByVal StartCol As Long, ByVal EndCol As Long, ByVal

ColValue As String, ByVal CurrentRow As Long) As Boolean

If StartCol EndCol Or StartCol GridObj.Cols Or CurrentRow GridObj.Rows Then

MsgBox "对不起,行列设置错误!", vbOKOnly, App.Title

MergeCol = False

Exit Function

End If

For I = StartCol To EndCol

GridObj.MergeCol(I) = True

GridObj.TextArray(faIndex(GridObj, CurrentRow, I)) = ColValue

GridObj.ColAlignment(I) = flexAlignCenterCenter

Next I

GridObj.MergeRow(CurrentRow) = True

MergeCol = True

End Function

''合并行

Public Function MergeRow(GridObj As Object, ByVal StartRow As Long, ByVal EndRow As Long, ByVal

RowValue As String, ByVal CurrentCol As Long) As Boolean

If StartRow EndRow Or StartRow GridObj.Rows Or CurrentCol GridObj.Cols Then

MsgBox "对不起,行列设置错误!", vbOKOnly, App.Title

MergeRow = False

Exit Function

End If

For I = StartRow To EndRow

GridObj.MergeRow(I) = True

GridObj.TextArray(faIndex(GridObj, I, CurrentCol)) = RowValue

GridObj.ColAlignment(CurrentCol) = flexAlignCenterCenter

Next I

GridObj.MergeCol(CurrentCol) = True

MergeRow = True

End Function

''转换索引

Public Function faIndex(GridObj As Object, ByVal row As Integer, ByVal col As Integer) As Long

If row GridObj.Rows Or row 0 Or col GridObj.Cols Or col 0 Then

MsgBox "对不起,行列设置错误!", vbOKOnly, App.Title

faIndex = -1

Exit Function

End If

faIndex = row * GridObj.Cols + col

End Function

''插入行

Public Function SetItem(GridObj As Object, ByVal row As Integer, ByVal col As Integer, ByVal

SetValue As String) As Boolean

If row GridObj.Rows Or row 0 Or col GridObj.Cols Or col 0 Then

MsgBox "对不起,行列设置错误!", vbOKOnly, App.Title

SetItem = False

Exit Function

End If

GridObj.TextArray(faIndex(GridObj, row, col)) = SetValue

SetItem = True

End Function

''得到单元格值

Public Function GetItem(GridObj As Object, ByVal row As Integer, ByVal col As Integer) As String

If row GridObj.Rows Or row 0 Or col GridObj.Cols Or col 0 Then

MsgBox "对不起,行列设置错误!", vbOKOnly, App.Title

GetItem = ""

Exit Function

End If

GetItem = GridObj.TextArray(faIndex(GridObj, row, col))

End Function

在msflexgrid控件中每一个cell格的内容是不可以由用户直接编辑的但是我们可以通过一些小技

巧来方便的实现这编辑功能来扩展msflexgrid的应用(在实际应用中这是很常用的功能)。

你只需按下面的做即可轻松实现编辑msflexgrid控件数据的功能

例在窗体上放一文本框txtvalue,和一msflexgrid控件grid

‘文本框控件的keypress事件

private sub txtvalue_keypress(keyascii as integer)

‘放入一些处理过程,如只需输入数字时的处理

dim i

i=1

end sub

private sub txtvalue_change()

grid.text = txtvalue.text

end sub

'在grid的entercell事件中加入下例代码

private sub grid_entercell()

txtvalue.text = grid.text

txtvalue.selstart = 0

txtvalue.sellength = len(txtvalue.text)

end sub

'当用户输入数据时直接调用文本框的keypress事件

private sub grid_keypress(keyascii as integer)

txtvalue_keypress keyascii

end sub

ok,这样一个可编辑的msflexgrid控件就完成了,简单吧!!

Private Sub fgrid1_click() '单击MSFlexGrid

sphy = Trim(FGrid1.TextMatrix(FGrid1.Row, 0))

delrecord

End Sub

Private Sub fgrid1_RowColChange()'用上下键在MSFlexGrid上选择

sphy = Trim(FGrid1.TextMatrix(FGrid1.Row, 0))

delrecord

End Sub

Private Sub DeleteRecord()'删除

Dim I As Integer '

Dim Ssql As String

Dim response As String

response = MsgBox("真的删除当前记录?", vbInformation + vbYesNo, "警告")

If response = vbYes Then

Ssql = "delete from login where loginname='" sphy "'"

gcnLeaguers.Execute (Ssql)

MsgBox "删除成功!", vbInformation + vbOKOnly, "系统提示"

End If

Exit Sub

End Sub

删除后可能还要刷新一下,你试试吧

MSHFlexGrid1.SelectionMode = flexSelectionByRow

还是

Private Sub Form_Load()

With MSHFlexGrid1

.FixedCols = 0

.Cols = 2

.Rows = 0

.AddItem "1" vbTab "11"

.AddItem "2" vbTab "22"

.AddItem "3" vbTab "33"

End With

End Sub

Private Sub MSHFlexGrid1_RowColChange()

Static intPrevRow As Long

If MSHFlexGrid1.Row intPrevRow Then

intPrevRow = MSHFlexGrid1.Row

Dim i As Long

For i = 0 To MSHFlexGrid1.Cols - 1

MsgBox MSHFlexGrid1.TextMatrix(intPrevRow, i)

Next

End If

End Sub

原理

当用户点击msflexgrid中的某个cell格要输入数据时,产生entercell事件,在这里我们对文本

框进行初始化,输入当前cell格中的内容,并且选中所有文本。当用户要按下按键进行输入时,就直

接调用txtvalue的事件,由文本框来处理.

处理的结果同grid的当前cell同步,使用户编辑cell格就象使用文本框一样方便。

网格单元格中文字的多行显示很简单,只要把WordWarp属性改为True就可以了。

1.VB6自带MSHFlexGrid只支持2048条记录显示,这个问题通过装VB6 的SP6解决.

2.TopRow属性的使用,这个属性可以使用代码移动MSHFlexGrid的行显示,如要做一个从上至下的滚动显示,使用这个属性解决起来非常方便

3.使用选码高亮即选中显示某一行,如要选中第三行,可以使用代码:

MSHFlexGrid1.Row = 3

MSHFlexGrid1.TopRow =3

myMSHFlexGrid.ColSel = MSHFlexGrid1.Cols - 1

MSHFlexGrid中单击某一行变色,如何实现?

Option Explicit

Public j As Long

Private Sub RowColor(i As Long, j As Long)

'i代表现在点的这一行

Dim n As Long 'n代表列

With Me.MSHFlexGrid1

For n = 1 To .Cols - 1

.Row = i

.Col = n

.CellBackColor = HC0FFFF

If j 0 And i j Then

.Row = j

.CellBackColor = HFFFFFF

End If

Next n

j = i

End With

End Sub

Private Sub Form_Load()

With Me.MSHFlexGrid1

.Cols = 5

.Rows = 6

End With

End Sub

Private Sub MSHFlexGrid1_Click()

Call RowColor(Me.MSHFlexGrid1.Row, j)

Debug.Print j

End Sub

在vb中怎么使按钮不可用,就是那种变灰色的

把按钮的Enable属性改为False。

用代码:按钮名.Enable=False。

用API:EnableWindow。

1、VB是一种可视化的面向对象的程序设计语言,Enabled是VB中控件的一种属性。

2、Enabled属性有两种值True和False,分别代表真和假。当一个控件的Enabled属性值为真时代表该控件可以用,当控件的Enabled属性为False时代表该控件不可用(图形会变度为灰色且不可以选中)。

扩展资料

vb.net 特性:

1、vb.net 完全集成到 Visual Studio 集成开发环境中,在这种集成开发环境与 VB 在若干方面有差异。主要体现在窗体的布局以及菜单等方面都有所不同。

2、vb.net 项目与 VB 不同。它使用基于文件夹的模型,所有项目均放置在项目文件夹层次结构中。

3、vb.net 中使用ado.net来访问数据库,ado.net是.netFramework的一部分。在 vb.net 中实现数据访问的方法主要有两种。

vb.net怎样使窗体半透明

窗体半透明: FormXX.Opacity=0.5或者: SetStyle(ControlStyles.SupportsTransparentBackColor, True)ControlXX.BackColor = Color.Transparent '或者是带Alpha的颜色ControlXX.BackColor = Color.FromArgb(128,Color.Red)

vb.net 如何使文字能渐变颜色,就是颜色慢慢变淡然后在慢慢恢复?

也容易,如果是黑白三个颜色加上相同的渐变量,彩色的是起始颜色的三个分量与终止颜色的对应三个分量的差值,再除于相同的份数,就得出三原色各自的步进量。

窗体上放个图片框试试下面代码:

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

visual studio 2013 中VB.net窗体的背景颜色不能设置为Transparent 求替代方法

Me.TransparencyKey = Color.White

'将窗体上的所有白色设为透明。

Me.BackColor = Color.White

'将窗体设为白色,若包括窗体上的控件颜色在内,没有其他颜色,则全部透明。

分享题目:关于vb.net浅灰的信息
文章分享:https://www.cdcxhl.com/article0/dochcio.html

成都网站建设公司_创新互联,为您提供网站维护App开发全网营销推广网站营销网站改版网站收录

广告

声明:本网站发布的内容(图片、视频和文字)以用户投稿、用户转载内容为主,如果涉及侵权请尽快告知,我们将会在第一时间删除。文章观点不代表本网站立场,如需处理请联系客服。电话:028-86922220;邮箱:631063699@qq.com。内容未经允许不得转载,或转载时需注明来源: 创新互联

成都网站建设