如何在Vsflexgrid上弹出flex tree右键菜单单?

下次自动登录
现在的位置:
& 综合 & 正文
如何实现将vsflexgrid中修改的数据反馈到数据库中
如何实现将vsflexgrid中修改的数据反馈到数据库中?Private Sub vsflexgrid1_AfterEdit(ByVal Row As Long, ByVal Col As Long)
rs.MoveFirst
'//rs为记录集
rs.Move vsflexgrid1.Row - 1
If vsflexgrid1.text = "" Then
rs.Fields(vsflexgrid1.Col - 1) = Null
rs.Fields(vsflexgrid1.Col - 1) = vsflexgrid1.text
rs.Updateend sub
一、增加记录使用for来循环表格行。
for i=1 to grid1.rows-1
.fileds(o)=grid1.textmariy(i,0)
.fileds(1)=grid1.textmariy(i,1)
.fileds(2)=grid1.textmariy(i,2)
.fileds(3)=grid1.textmariy(i,3)
next二、添加行  grid1.additem row三、删除当前行  with grid1
.removeitem i
end with四、要显示下拉框,可以使用vsflexgrid中列绑定功能  grid1.colcombolist(1)=grid.buildcombolist(rs,"商品名称") 跟楼上的相比,仅仅是datamode不一样(2-flexDMBoundBatch)但这样做的优势是非常明显的:可以撤销包括新增删除在内的所有操作,按保存键才写入数据库
Private Sub CmdDel_Click()
fg.Row && 0 Then fg.RemoveItem (fg.Row)
fg.Refresh
Private Sub CmdAdd_Click()On Error Resume NextAdodc1.Recordset.AddNewIf Err.Number && 0 Then MsgBox Err.DescriptionEnd Sub
Private Sub CmdUpdate()Adodc1.Recordset.UpdateBatch adAffectAllChaptersEnd Sub
Private Sub CmdCancel_Click()
Adodc1.Recordset.CancelBatch
fg.DataRefreshEnd Sub
Private Sub Form_Load()Adodc1.ConnectionString = "FILE NAME=" & App.Path & "/conn.dsn"Adodc1.LockType = adLockBatchOptimisticAdodc1.RecordSource = "Your_Tablename"Set fg.DataSource = Adodc1End Sub
1、打印vsflexgrid可以使用vsprinter打印控件。跟vsflexgrid配套使用效果不错。2、导出EXECL,可以使用grid.savegrid的方法。
用savegrid的方法 ,在导出execl时,如果碰到类似于银行帐号的列如:“6465456665”,导到EXECL中就不这样显示了,这个问题还不知道怎么解决??
另外也可以写(这个方法比较实用,但慢一些):
Dim excelApp As Excel.Application
Set excelApp = New Excel.Application
On Error Resume Next
If excelApp Is Nothing Then
Set excelApp = CreateObject("Excel.application")
If excelApp Is Nothing Then
excelApp.Visible = True
Me.MousePointer = vbHourglass
excelApp.Workbooks.Add
With excelApp.ActiveSheet
Dim i As Integer, j As Integer
For i = 1 To Grid1.rows
For j = 1 To Grid1.Cols
.Cells(i, j).value ="'"& Grid1.TextMatrix((i - 1), (j - 1))'加上“'”号则可以解决上面savegrid中银行帐号的导出问题。
Me.MousePointer = vbDefault
Set excelApp = NothingEnd Sub
EXCEL同Vsflexgrid通过最近很多的朋友,都想知道EXCEL怎样同VSflexgrid交换数据。实际上,利用“复制”、“粘贴”菜单即可实现。具体如下:(1)在Vsflexgrid上弹出右键菜单
Private Sub grid1_MouseDown(Button As Integer, Shift As Integer, X As Single, y
As Single)
Button = 2 Then
PopupMenu mnutccd
End Sub(2)设置各菜单的内容A 复制
Clipboard.Clear
Clipboard.SetText grid1.ClipB 剪切
Dim rowc As Long
Dim rowz As Long
Dim colc As Long
dim colz As Long
dim i as long
dim s as long
If grid1.Rows = 1 Then Exit Sub
Clipboard.Clear
Clipboard.SetText grid1.Clip
If grid1.RowSel & grid1.row Then
rowc = grid1.row
rowz = grid1.RowSel
rowc = grid1.RowSel
rowz = grid1.row
If grid1.ColSel & grid1.Col Then
colc = grid1.Col
colz = grid1.ColSel
colc = grid1.ColSel
colz = grid1.Col
For i = rowc To rowz
For s = colc To colz
grid1.TextMatrix(i, s) = ""
NextC 粘贴(精华部分)
Dim i As Long
Dim s As Long
Dim m As Long
Dim t As Long
If grid1.Rows = 1 Then Exit Sub
t = Len(Clipboard.GetText)
If t = 0 Then Exit Sub
For i = 1 To t
If Mid(Clipboard.GetText, i, 1) = Chr(9) Then s = s + 1
If Mid(Clipboard.GetText, i, 1) = Chr(13) Then m = m + 1
If s / (m + 1) + grid1.Col & grid1.Cols - 1 Then
grid1.ColSel = grid1.Cols - 1
grid1.ColSel = s / (m + 1) + grid1.Col
If grid1.row + m & grid1.Rows - 1 Then
grid1.RowSel = grid1.Rows - 1
grid1.RowSel = grid1.row + m
grid1.Clip = Clipboard.GetText
VSFlexGrid 常用属性或方法: .FixedRows = 1
'固定几行.FixedCols = 1
'固定几列.Editable = True
'允许修改.AllowUserResizing = flexResizeBoth
'可调整行/列.FocusRect = flexFocusNone
'无虚框.SelectionMode = flexSelectionListBox
'焦点选中样式.BackColor = RGB(255, 255, 255)
'单元背景色.BackColorSel = vbBlue
'单元选择色.BackColorFixed = RGB(208, 192, 160)
'固定单元色.BackColorAlternate = RGB(255, 250, 230)
'间隔行背景色.GridColor = RGB(245, 240, 210)
'单元线条色.ForeColor = RGB(0, 0, 0)
'单元前景色(字符色).RowHeightMin = 260
'最小行高.RowHeightMax = 800
'最大行高.ColHeightMin = 50
'最小列宽.ColHeightMax = 3000
'最大列宽.ColWidth(Col) = 1000
'指定列宽.RowHeight(Row) = 260
'指定行高.TextMatrix(Row,Col) = "Text"
'指定单元字符.Text = "Text"
'选定单元字符.MergeCol(Col) = True
'允许合并列.MergeRow(Row) = True
'允许合并行.MergeCells = 0|1|2|3|4|5|6
'合并选项.Cell(选项准则, Row1, Col1, Row2, Col2)
'选择部分的相应准则值.EditCell
'当移动到当前单元时自动选择.EditSelStart
'移动到单元时的光标位置.MousePointer
'设置对象的鼠标指针样式 O.A = 0 到 15|99━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━几个特殊的属性方法的使用:FormatString 属性:管道符格式化字符串示例:下面定义对齐方式同字意,列宽窄同距离VSG1.FormatString = "^
"+++++++++++++++++++++++++搜索(查找)表格中符合条件的行:FindRow 属性:该属性返回一个行值MsgBox VSG1.FindRow(关键词,[指定行],[指定列],[敏感],[精度])关键词:String,表示要搜索的字符串指定行/指定列:Long,表示只在指定的行或列中找敏感:Boolean,━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━'限制只能在指定列输入(这里默认倒数第2列)Private Sub VSG1_BeforeRowColChange(ByVal OldRow As Long, _
ByVal OldCol As Long, ByVal NewRow As Long, _
ByVal NewCol As Long, Cancel As Boolean)
VSG1.Editable = flexEDKbd
If VSG1.Redraw && flexRDNone And NewCol && VSG1.Cols - 2 Then
Cancel = True
VSG1.Select NewRow, VSG1.Cols - 2
End IfEnd Sub━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━限制不能编辑某些列:(这里限制第1列和第3列)Private Sub VSG1_RowColChange()
If VSG1.Col = 1 Or VSG1.Col = 3 Then
VSG1.FocusRect = flexFocusNone
VSG1.Editable = flexEDNone
'SendKeys "{TAB}"
VSG1.Editable = flexEDKbd
SendKeys "{ENTER}"
End IfEnd Sub或:Private Sub VSG1_RowColChange()If VSG1.Col = 1 Or VSG1.Col = 3 Then
SendKeys "{RIGHT}"Else
SendKeys "{ENTER}"End IfEnd Sub或:Private Sub VSG1_RowColChange()If VSG1.Col = 1 Or VSG1.Col = 3 Then
VSG1.Editable = flexEDNoneElse
VSG1.Editable = flexEDKbd
VSG1.EditCell
'自动选择单元内容
VSG1.EditSelStart = 0[选到最前]|1[选到指定]|Len(VSG1.Text)[选到最后]End IfEnd Sub━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━'对齐方式(-1标示所有).ColAlignment(-1) = flexAlignLeftCenter|flexAlignCenterCenter|flexAlignRightCenter示例1:(最后一行的第3列靠右对齐)VSG1.Select VSG1.Rows - 1, 2VSG1.CellAlignment = flexAlignRightCenter示例2:VSG1.Row = VSG1.Rows - 1: VSG1.Col = 1VSG1.CellAlignment = flexAlignRightCenter示例3:VSG1.Cell(flexcpAlignment, VSG1.Rows - 1, 1, VSG1.Rows - 1, 3) = flexAlignRightCenter━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━本对象拖放:Private Sub VSG1_MouseDown(Button As Integer, _
Shift As Integer, X As Single, Y As Single)VSG1.DragVSG1.DragIcon = LoadPicture("D:/Icon.ico")VSG1.DragRow VSG1.RowSelEnd Sub或从其它对象拖:Private Sub VSG2_MouseDown(Button As Integer, _
Shift As Integer, X As Single, Y As Single)VSG2.OLEDragVSG1.OLEDropMode = flexOLEDropAutomaticEnd Sub━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━Public Sub VSGridCount(Optional SelRow As Long, Optional SelCol As Long)Dim X As Long, i As LongDim Hj1, Hj2, Hj3 As StringConst A1 = -477#, A2 = 477#On Error GoTo ErrTransactWith frmFG.VSG1
X = .Rows - 1
.MergeCells = flexMergeFree
.MergeRow(X) = True
.Cell(flexcpText, X, 0, X, 1) = "合 计"
If .Rows = 3 Then
.TextMatrix(X, 0) = 0
.Cell(flexcpText, X, 2, X, 14) = " "
.Cell(flexcpText, X, 16, X, 17) = "¥0.00"
'Hj1 = Val(.Aggregate(flexSTSum, 2, 2, X - 1, 2))
'Hj2 = Val(.Aggregate(flexSTSum, 2, 16, X - 1, 16))
'Hj3 = CurrencyToStr(Hj2)
For i = 2 To X - 2
Hj1 = Hj1 + Val(.TextMatrix(i, 15))
If Val(.TextMatrix(i, 16)) & 0 Then
Hj2 = Hj2 + Val(.TextMatrix(i, 15)) * Val(.TextMatrix(i, 16))
If Hj2 &= A1 Or Hj2 &= A2 Then
GoTo ErrTransact
Hj3 = CurrencyToStr(Hj2)
.TextMatrix(X, 2) = Hj1
.Cell(flexcpText, X, 3, X, 15) = IIf(Hj3 = "", " ", Hj3)
.Cell(flexcpText, X, 16, X, 17) = Format(Hj2, "¥0.00")
.Cell(flexcpAlignment, X, 2, X, 14) = flexAlignLeftCenter
'.Select X, 3
'.CellAlignment = flexAlignLeftCenter
If SelRow & 1 And SelCol & 0 Then .Select SelRow, SelColEnd WithExit SubErrTransact:
MsgBox "你输入的数字过大无法计算!请修改!!!"End Sub------------------------------------------------将数字转换为大写金额的函数:Function CurrencyToStr(ByVal Number As Currency) As String
Number = Val(Trim(Number))
If Number = 0 Then CurrencyToStr = "": Exit Function
Dim str1Ary As Variant, str2Ary As Variant
str1Ary = Split("零 壹 贰 叁 肆 伍 陆 柒 捌 玖")
str2Ary = Split("分 角 元 拾 佰 仟 万 拾 佰 仟 亿 拾 佰 仟 万 拾 佰")
Dim a As Long, b As Long
Dim tmp1 As String
Dim tmp2 As String
'临时转换结果
Dim Point As Long
'小数点位置
If Number &= -477# Or Number &= 477# Then
Exit Function
tmp1 = Round(Number, 2)
tmp1 = Replace(tmp1, "-", "")
'先去掉“-”号
Point = InStr(tmp1, ".")
'取得小数点位置
If Point = 0 Then
'如果有小数点,最大佰万亿
b = Len(tmp1) + 2
'加2位小数
b = Len(Left(tmp1, Point + 1))
'包括点加2位小数
''先将所有数字替换为中文
For a = 9 To 0 Step -1
tmp1 = Replace(Replace(tmp1, a, str1Ary(a)), ".", "")
For a = 1 To b
If Mid(tmp1, a, 1) && "" Then
If b & UBound(str2Ary) Then Exit For
tmp2 = tmp2 & Mid(tmp1, a, 1) & str2Ary(b)
If tmp2 = "" Then CurrencyToStr = "": Exit Function
''〓下面为非正式财务,可以去掉〓
For a = 1 To Len(tmp2)
tmp2 = Replace(tmp2, "零亿", "亿零")
tmp2 = Replace(tmp2, "零万", "万零")
tmp2 = Replace(tmp2, "零仟", "零")
tmp2 = Replace(tmp2, "零佰", "零")
tmp2 = Replace(tmp2, "零拾", "零")
tmp2 = Replace(tmp2, "零元", "元")
tmp2 = Replace(tmp2, "零零", "零")
tmp2 = Replace(tmp2, "亿万", "亿")
''〓上面为非正式财务算法,可以去掉〓
If Point = 1 Then tmp2 = "零元" + tmp2
If Number & 0 Then tmp2 = "负" + tmp2
If Point = 0 Then tmp2 = tmp2 + "整"
CurrencyToStr = tmp2End Function━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━Cell 属性的使用:Cell 的作用是给以选定区块的特定的设置值,具体值可参阅相应属性值。语法:Cell(条件准则, Row1, Col1, Row2, Col2) = 相应准则值其中的“条件准则”有以下准则常数,根据准则的不同而设置相应准则的值:flexcpAlignment
对齐方式flexcpBackColor
背景色flexcpChecked
选择框flexcpCustomFormat
格式设置flexcpData
日期flexcpFloodColor
颜色flexcpFloodPercent
背景色flexcpFont
字体flexcpFontBold
粗体flexcpFontItalic
斜体flexcpFontName
字体名flexcpFontSize
字体大小flexcpFontStrikethru
删除线flexcpFontUnderline
下划线flexcpFontWidth
字符宽flexcpForeColor
字符色flexcpHeight
高flexcpLeft
左flexcpPicture
添加图flexcpPictureAlignment 图对齐flexcpRefresh
刷新flexcpSort
分类flexcpText
字符flexcpTextDisplay
显示字符flexcpTextStyle
文本样式flexcpTop
返回顶端高,同 RowPos 和 valueMatrix 属性flexcpvalue
返回字符值flexcpVariantvalue
返回字符值flexcpWidth
返回单元宽━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━flexSTSum 方法:每行增加小计行[这个方法还不会用]语法:VSG.flexSTSum 常数名,[GroupOn As Long], :标签列[TotalOn As Long], :计算列[Format As String], :格式,例 "$0.00"[BackColor As Color], :Color[ForeColor As Color], :Color[FontBold As Boolean], :False|True[Caption As String], :例 "数 %s"[MatchFrom As Integer], :0|1|2|3[TatalOnly As Boolean] :False|True常数名:常数
说明flexSTNone
大纲唯一的,没有合计价值flexSTClear
清除全部的小计flexSTSum
总数flexSTPercent
总数的百分比flexSTCount
行数flexSTAverage
平均flexSTMax
最大的flexSTMin
最小的flexSTStd
标准偏差flexSTVar
方差━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━MousePointer、MouseIcon 鼠标指针的应用:0=flexDefault1=flexArrow2=flexCross3=flexIBeam4=flexIcon5=flexSize6=flexSizeNESW7=flexSizeNS8=flexSizeNWSE9=flexSizeEW10=flexUpArrow11=flexHourglass12=flexNoDrop13=flexArrowHourGlass14=flexArrowQuestion15=flexSizeAll50=flexPointerCopy
'(&H32) '拖动带拷贝51=flexPointerMove
'(&H33) '拖动52=flexSizeHorz
'(&H34) '左右调整53=flexSizeVert
'(&H35) '上下调整54=flexHand
'(&H36) 手型99=flexCustom '自定义Const MA = "50,51,52,53,54"Dim xy As Integerxy = Val(Text1.Text)If xy & 15 And xy && 99 And InStr(MA, xy) = 0 Then xy = 15VSG1.MousePointer = xyIf xy = 99 Then
VSG1.MouseIcon = LoadPicture("C:/icon/Icon.ico")End If━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━单击列头将列互相拖动调换:方法一:VSG1.ExplorerBar = flexExMove
'2 这是最简单的方法了注意这个属性在VB属性表中只设置了0、1、2、3、5、7、8种常数值ExplorerBar 属性(value=0|1|2|3|5|7|8):
0-flexExNone:默认,单击列头选择整列,单击行头选择整行
1-flexExSort:单击列头可正反排序该列,单击行头选择整行
2-flexExMove:单击列头可交换列顺序,单击行头选择整行
3-flexExSortAndMove:具有 1 和 2 的功能
4:单击列头可正反排序该列并在列头显示相应箭头,单击行头选择整行
5-flexExSortShow:好像与 4 相同也
6:具有 2 和 4 的功能
7-flexExSortShowAndMove:好像与 6 相同也
8-flexExMoveRows:单击列头选择整列,可拖动行
9:单击列头可正反排序该列,可拖动行
10:可拖动行与列
11:可排序列及拖动行列
12:可排序列并在列头显示相应箭头,还可拖动行
13:同 12。
14:除 12 功能外,可拖动列
15:同 14。方法二:Private Sub VSG1_MouseDown(Button As Integer, Shift As Integer, X As Single, Y As Single)
Dim r%, c%
r = VSG1.MouseRow
c = VSG1.MouseCol
If r = 0 And c & 0 Then
VSG1.Tag = c
VSG1.Cell(flexcpBackColor, 0, c) = vbYellow
VSG1.MousePointer = flexPointerMove
End IfEnd SubPrivate Sub VSG1_MouseMove(Button As Integer, Shift As Integer, X As Single, Y As Single)
If Len(VSG1.Tag) Then
Dim r%, c%, p%
r = VSG1.MouseRow
c = VSG1.MouseCol
If r = 0 And c & 0 Then p = flexPointerMove
If VSG1.MousePointer && p Then VSG1.MousePointer = p
End IfEnd SubPrivate Sub VSG1_MouseUp(Button As Integer, Shift As Integer, X As Single, Y As Single)
If Len(VSG1.Tag) Then
Dim r%, c%, target%
target = VSG1.Tag
VSG1.Cell(flexcpBackColor, 0, target) = 0
VSG1.Tag = ""
VSG1.MousePointer = 0
r = VSG1.MouseRow
c = VSG1.MouseCol
If r = 0 And c & 0 And c && target Then
VSG1.ColPosition(target) = c
End IfEnd Sub━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━VSFlexString控件属性一览表CaseSensitive
失败时取得错误信息Index
索引MatchCount
取得与检索条件相一致的字符串数量MatchIndex
设定与检索条件相一致的字符串的索引MatchLength
取得与检索条件相一致的字符串长度MatchStart
取得与检索条件相一致的字符串起始位置MatchString
取得与检索条件相一致的字符串NameObjectParentPattern
设定检索条件Replace
设定置换字符串Soundex
取得代表当前检索字符的声音代码TagTagCount
取得与检索条件相一致的标签数量TagIndex
在多个标签情况下,设定/取得与检索条件相一致的标签索引TagLength
取得与检索条件相一致的标签长度TagStart
取得与检索条件相一致的标签起始位置TagString
取得与检索条件相一致的标签的字符串Text
设定成为检索对象Version
取得FlexString的版本号--------------------------------------------------------
MSFlexGrid与VSFlexGrid的单元格合并例子:
Private Sub Form_Load()Dim i As LongWith fg
.WordWrap = True
.FixedRows = 2
.FixedCols = 0
.ColWidth(0) = 1500
.RowHeight(0) = 300
.RowHeight(1) = 300
.TextMatrix(1, 1) = "进货"
.TextMatrix(1, 2) = "销售"
.TextMatrix(1, 3) = "退货"
.TextMatrix(1, 4) = "结存"
For i = 1 To .Rows - 1
.RowHeight(i) = 300
For i = 0 To 1
.TextMatrix(i, 0) = "上月" & vbCrLf & "结存数量"
.FixedAlignment(0) = 4
For i = 0 To 1
.TextMatrix(i, 5) = "月末结存"
.FixedAlignment(5) = 4
For i = 1 To 4
.TextMatrix(0, i) = "本月进销存数量"
.ColAlignment(i) = 4
.MergeCells = flexMergeFree'
.MergeCells = flexMergeFixedOnly
.MergeCol(0) = True
.MergeRow(0) = True
.MergeCol(5) = TrueEnd With End Sub
请问:如何使用 VSFlexGrid Pro 分级显示和存取数据库中的数据。类似于《让 TreeView 支持无限级分类》帖子中所介绍的使用树形控件显示和存取数据库的数据。
Dim cn as New ADODB.RecordsetDim rs As New ADODB.RecordsetDim lngY As LongDim intT As Integer cn.open "............"rs.Open "select 系统编号 from test order by 系统编号", cnWith VSFlexGrid1
Set .DataSource = rs
.RowOutlineLevel(1) = 1
.IsSubtotal(1) = True
For lngY = 1 To .Rows - 1
intT = Len(.TextMatrix(lngY, 0)) - Len(Replace(.TextMatrix(lngY, 0), ".", ""))
.RowOutlineLevel(lngY) = intT
.IsSubtotal(lngY) = True
.OutlineCol = 0
.OutlineBar = flexOutlineBarSimpleLeaf
Set VSFlexGrid1.DataSource = Rs'这一步一定要有,With VSFlexGrid1
.DataRefresh
.Sort = flexSortGenericDescending'排序
&&&&推荐文章:
【上篇】【下篇】8490人阅读
如何实现将vsflexgrid中修改的数据反馈到数据库中??Private&Sub&vsflexgrid1_AfterEdit(ByVal&Row&As&Long,&ByVal&Col&As&Long)&&rs.MoveFirst&&&&'//rs为记录集&&rs.Move&vsflexgrid1.Row&-&1&&rs.Edit&&If&vsflexgrid1.text&=&&&&Then&&&&&&rs.Fields(vsflexgrid1.Col&-&1)&=&Null&&Else&&&&&rs.Fields(vsflexgrid1.Col&-&1)&=&vsflexgrid1.text&&End&If&&rs.Updateend&sub&&&一、增加记录使用for来循环表格行。&&&&&for&i=1&to&grid1.rows-1&&&&&&&&&&with&rs&&&&&&&&&&&&&&&&&.addnew&&&&&&&&&&&&&&&&&.fileds(o)=grid1.textmariy(i,0)&&&&&&&&&&&&&&&&&.fileds(1)=grid1.textmariy(i,1)&&&&&&&&&&&&&&&&&.fileds(2)=grid1.textmariy(i,2)&&&&&&&&&&&&&&&&&.fileds(3)=grid1.textmariy(i,3)&&&&&&&&&&&&&&&&&.update&&&&&&&&&&&end&with&&&&&&next二、添加行  grid1.additem&row三、删除当前行  with&grid1&&&&&&&&&&&&i=.row&&&&&&&&&&&&.removeitem&i&&&&&&end&with四、要显示下拉框,可以使用vsflexgrid中列绑定功能  grid1.colcombolist(1)=grid.buildcombolist(rs,&商品名称&)&跟楼上的相比,仅仅是datamode不一样(2-flexDMBoundBatch)但这样做的优势是非常明显的:可以撤销包括新增删除在内的所有操作,按保存键才写入数据库Private&Sub&CmdDel_Click()If&fg.Row&&&&0&Then&fg.RemoveItem&(fg.Row)fg.RefreshEnd&SubPrivate&Sub&CmdAdd_Click()On&Error&Resume&NextAdodc1.Recordset.AddNewIf&Err.Number&&&&0&Then&MsgBox&Err.DescriptionEnd&SubPrivate&Sub&CmdUpdate()Adodc1.Recordset.UpdateBatch&adAffectAllChaptersEnd&SubPrivate&Sub&CmdCancel_Click()&&&&Adodc1.Recordset.CancelBatch&&&&fg.DataRefreshEnd&SubPrivate&Sub&Form_Load()Adodc1.ConnectionString&=&&FILE&NAME=&&&&App.Path&&&&/conn.dsn&Adodc1.LockType&=&adLockBatchOptimisticAdodc1.RecordSource&=&&Your_Tablename&Set&fg.DataSource&=&Adodc1End&Sub&&1、打印vsflexgrid可以使用vsprinter打印控件。跟vsflexgrid配套使用效果不错。2、导出EXECL,可以使用grid.savegrid的方法。&&&用savegrid的方法&,在导出execl时,如果碰到类似于银行帐号的列如:&6465456665&,导到EXECL中就不这样显示了,这个问题还不知道怎么解决??&&&&另外也可以写代码(这个方法比较实用,但慢一些):&&&Dim&excelApp&As&Excel.Application&&&&Set&excelApp&=&New&Excel.Application&&&&On&Error&Resume&Next&&&&If&excelApp&Is&Nothing&Then&&&&&&&Set&excelApp&=&CreateObject(&Excel.application&)&&&&&&&If&excelApp&Is&Nothing&Then&&&&&&&&&&Exit&Sub&&&&&&&End&If&&&&End&If&&&&excelApp.Visible&=&True&&&&Me.MousePointer&=&vbHourglass&&&&excelApp.Workbooks.Add&&&&With&excelApp.ActiveSheet&&&&&&&&Dim&i&As&Integer,&j&As&Integer&&&&&&&&For&i&=&1&To&Grid1.rows&&&&&&&&&&&&For&j&=&1&To&Grid1.Cols&&&&&&&&&&&&&&&&&&.Cells(i,&j).value&=&'&&&Grid1.TextMatrix((i&-&1),&(j&-&1))'加上&'&号则可以解决上面savegrid中银行帐号的导出问题。&&&&&&&&&&&&&Next&j&&&&&&&&&&&&DoEvents&&&&&&&&Next&i&&&&End&With&&&&Me.MousePointer&=&vbDefault&&&&Set&excelApp&=&NothingEnd&Sub&&EXCEL同Vsflexgrid通过最近很多的朋友,都想知道EXCEL怎样同VSflexgrid交换数据。实际上,利用&复制&、&粘贴&菜单即可实现。具体如下:(1)在Vsflexgrid上弹出右键菜单&&Private&Sub&grid1_MouseDown(Button&As&Integer,&Shift&As&Integer,&X&As&Single,&y&&&As&Single)&&&&if&&Button&=&2&Then&&PopupMenu&mnutccd&&End&Sub(2)设置各菜单的内容A&复制&&&&Clipboard.Clear&&&&Clipboard.SetText&grid1.ClipB&剪切&&&Dim&rowc&As&Long&&&Dim&rowz&As&Long&&&Dim&colc&As&Long&&&dim&colz&As&Long&&&dim&i&as&long&&&&dim&s&as&long&&&If&grid1.Rows&=&1&Then&Exit&Sub&&&Clipboard.Clear&&Clipboard.SetText&grid1.Clip&&&If&grid1.RowSel&&&grid1.row&Then&&&&&&&rowc&=&grid1.row&&&&&&&rowz&=&grid1.RowSel&&&Else&&&&&&&rowc&=&grid1.RowSel&&&&&&rowz&=&grid1.row&&&End&If&&&If&grid1.ColSel&&&grid1.Col&Then&&&&&&colc&=&grid1.Col&&&&&&colz&=&grid1.ColSel&&&Else&&&&&&colc&=&grid1.ColSel&&&&&&colz&=&grid1.Col&&&&End&If&&&&For&i&=&rowc&To&rowz&&&&&&&For&s&=&colc&To&colz&&&&&&&&&&&grid1.TextMatrix(i,&s)&=&&&&&&&&&Next&&&&NextC&粘贴(精华部分)&&Dim&i&As&Long&&Dim&s&As&Long&&Dim&m&As&Long&&Dim&t&As&Long&&&If&grid1.Rows&=&1&Then&Exit&Sub&&&t&=&Len(Clipboard.GetText)&&&If&t&=&0&Then&Exit&Sub&&&For&i&=&1&To&t&&&&&&If&Mid(Clipboard.GetText,&i,&1)&=&Chr(9)&Then&s&=&s&+&1&&&&&&If&Mid(Clipboard.GetText,&i,&1)&=&Chr(13)&Then&m&=&m&+&1&&&Next&&&If&s&/&(m&+&1)&+&grid1.Col&&&grid1.Cols&-&1&Then&&&&&&&grid1.ColSel&=&grid1.Cols&-&1&&&Else&&&&&&grid1.ColSel&=&s&/&(m&+&1)&+&grid1.Col&&&End&If&&&If&grid1.row&+&m&&&grid1.Rows&-&1&Then&&&&&&&grid1.RowSel&=&grid1.Rows&-&1&&&Else&&&&&&&grid1.RowSel&=&grid1.row&+&m&&&End&If&&&grid1.Clip&=&Clipboard.GetText&&&VSFlexGrid&常用属性或方法:&.FixedRows&=&1&&&&&&&&&&&&&&&&&&&&&&&&&&&&'固定几行.FixedCols&=&1&&&&&&&&&&&&&&&&&&&&&&&&&&&&'固定几列.Editable&=&True&&&&&&&&&&&&&&&&&&&&&&&&&&'允许修改.AllowUserResizing&=&flexResizeBoth&&&&&&&'可调整行/列.FocusRect&=&flexFocusNone&&&&&&&&&&&&&&&&'无虚框.SelectionMode&=&flexSelectionListBox&&&&&'焦点选中样式.BackColor&=&RGB(255,&255,&255)&&&&&&&&&&&'单元背景色.BackColorSel&=&vbBlue&&&&&&&&&&&&&&&&&&&&'单元选择色.BackColorFixed&=&RGB(208,&192,&160)&&&&&&'固定单元色.BackColorAlternate&=&RGB(255,&250,&230)&&'间隔行背景色.GridColor&=&RGB(245,&240,&210)&&&&&&&&&&&'单元线条色.ForeColor&=&RGB(0,&0,&0)&&&&&&&&&&&&&&&&&'单元前景色(字符色).RowHeightMin&=&260&&&&&&&&&&&&&&&&&&&&&&&'最小行高.RowHeightMax&=&800&&&&&&&&&&&&&&&&&&&&&&&'最大行高.ColHeightMin&=&50&&&&&&&&&&&&&&&&&&&&&&&&'最小列宽.ColHeightMax&=&3000&&&&&&&&&&&&&&&&&&&&&&'最大列宽.ColWidth(Col)&=&1000&&&&&&&&&&&&&&&&&&&&&'指定列宽.RowHeight(Row)&=&260&&&&&&&&&&&&&&&&&&&&&'指定行高.TextMatrix(Row,Col)&=&&Text&&&&&&&&&&&&&&'指定单元字符.Text&=&&Text&&&&&&&&&&&&&&&&&&&&&&&&&&&&&'选定单元字符.MergeCol(Col)&=&True&&&&&&&&&&&&&&&&&&&&&'允许合并列.MergeRow(Row)&=&True&&&&&&&&&&&&&&&&&&&&&'允许合并行.MergeCells&=&0|1|2|3|4|5|6&&&&&&&&&&&&&&&'合并选项.Cell(选项准则,&Row1,&Col1,&Row2,&Col2)&&&'选择部分的相应准则值.EditCell&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&'当移动到当前单元时自动选择.EditSelStart&&&&&&&&&&&&&&&&&&&&&&&&&&&&&'移动到单元时的光标位置.MousePointer&&&&&&&&&&&&&&&&&&&&&&&&&&&&&'设置对象的鼠标指针样式&O.A&=&0&到&15|99━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━几个特殊的属性方法的使用:FormatString&属性:管道符格式化字符串示例:下面定义对齐方式同字意,列宽窄同距离VSG1.FormatString&=&&^&&中&|&&&&&&左&&&&|&&&&右&&|&&&&右&&|^&&中&&&+++++++++++++++++++++++++搜索(查找)表格中符合条件的行:FindRow&属性:该属性返回一个行值MsgBox&VSG1.FindRow(关键词,[指定行],[指定列],[敏感],[精度])关键词:String,表示要搜索的字符串指定行/指定列:Long,表示只在指定的行或列中找敏感:Boolean,━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━'限制只能在指定列输入(这里默认倒数第2列)Private&Sub&VSG1_BeforeRowColChange(ByVal&OldRow&As&Long,&_&&&&&&&ByVal&OldCol&As&Long,&ByVal&NewRow&As&Long,&_&&&&&&&ByVal&NewCol&As&Long,&Cancel&As&Boolean)&&VSG1.Editable&=&flexEDKbd&&If&VSG1.Redraw&&&&flexRDNone&And&NewCol&&&&VSG1.Cols&-&2&Then&&&&&Cancel&=&True&&&&&VSG1.Select&NewRow,&VSG1.Cols&-&2&&End&IfEnd&Sub━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━限制不能编辑某些列:(这里限制第1列和第3列)Private&Sub&VSG1_RowColChange()&&&If&VSG1.Col&=&1&Or&VSG1.Col&=&3&Then&&&&&&VSG1.FocusRect&=&flexFocusNone&&&&&&VSG1.Editable&=&flexEDNone&&&&&'SendKeys&&{TAB}&&&&Else&&&&&&VSG1.Editable&=&flexEDKbd&&&&&&SendKeys&&{ENTER}&&&&End&IfEnd&Sub或:Private&Sub&VSG1_RowColChange()If&VSG1.Col&=&1&Or&VSG1.Col&=&3&Then&&&SendKeys&&{RIGHT}&Else&&&SendKeys&&{ENTER}&End&IfEnd&Sub或:Private&Sub&VSG1_RowColChange()If&VSG1.Col&=&1&Or&VSG1.Col&=&3&Then&&&VSG1.Editable&=&flexEDNoneElse&&&VSG1.Editable&=&flexEDKbd&&&VSG1.EditCell&&'自动选择单元内容&&&VSG1.EditSelStart&=&0[选到最前]|1[选到指定]|Len(VSG1.Text)[选到最后]End&IfEnd&Sub━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━'对齐方式(-1标示所有).ColAlignment(-1)&=&flexAlignLeftCenter|flexAlignCenterCenter|flexAlignRightCenter示例1:(最后一行的第3列靠右对齐)VSG1.Select&VSG1.Rows&-&1,&2VSG1.CellAlignment&=&flexAlignRightCenter示例2:VSG1.Row&=&VSG1.Rows&-&1:&VSG1.Col&=&1VSG1.CellAlignment&=&flexAlignRightCenter示例3:VSG1.Cell(flexcpAlignment,&VSG1.Rows&-&1,&1,&VSG1.Rows&-&1,&3)&=&flexAlignRightCenter━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━本对象拖放:Private&Sub&VSG1_MouseDown(Button&As&Integer,&_&&&&&&&&Shift&As&Integer,&X&As&Single,&Y&As&Single)VSG1.DragVSG1.DragIcon&=&LoadPicture(&D:/Icon.ico&)VSG1.DragRow&VSG1.RowSelEnd&Sub或从其它对象拖:Private&Sub&VSG2_MouseDown(Button&As&Integer,&_&&&&&&&&Shift&As&Integer,&X&As&Single,&Y&As&Single)VSG2.OLEDragVSG1.OLEDropMode&=&flexOLEDropAutomaticEnd&Sub━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━Public&Sub&VSGridCount(Optional&SelRow&As&Long,&Optional&SelCol&As&Long)Dim&X&As&Long,&i&As&LongDim&Hj1,&Hj2,&Hj3&As&StringConst&A1&=&-477#,&A2&=&477#On&Error&GoTo&ErrTransactWith&frmFG.VSG1&&&X&=&.Rows&-&1&&&.MergeCells&=&flexMergeFree&&&.MergeRow(X)&=&True&&&.Cell(flexcpText,&X,&0,&X,&1)&=&&合&计&&&&If&.Rows&=&3&Then&&&&&&.TextMatrix(X,&0)&=&0&&&&&&.Cell(flexcpText,&X,&2,&X,&14)&=&&&&&&&&&&.Cell(flexcpText,&X,&16,&X,&17)&=&&¥0.00&&&&&&&Exit&Sub&&&End&If&&&'Hj1&=&Val(.Aggregate(flexSTSum,&2,&2,&X&-&1,&2))&&&'Hj2&=&Val(.Aggregate(flexSTSum,&2,&16,&X&-&1,&16))&&&'Hj3&=&CurrencyToStr(Hj2)&&&For&i&=&2&To&X&-&2&&&&&&&Hj1&=&Hj1&+&Val(.TextMatrix(i,&15))&&&&&&&If&Val(.TextMatrix(i,&16))&&&0&Then&&&&&&&&&&Hj2&=&Hj2&+&Val(.TextMatrix(i,&15))&*&Val(.TextMatrix(i,&16))&&&&&&&End&If&&&Next&i&&&If&Hj2&&=&A1&Or&Hj2&&=&A2&Then&&&&&GoTo&ErrTransact&&&End&If&&&Hj3&=&CurrencyToStr(Hj2)&&&.TextMatrix(X,&2)&=&Hj1&&&.Cell(flexcpText,&X,&3,&X,&15)&=&IIf(Hj3&=&&&,&&&&,&Hj3)&&&.Cell(flexcpText,&X,&16,&X,&17)&=&Format(Hj2,&&¥0.00&)&&&.Cell(flexcpAlignment,&X,&2,&X,&14)&=&flexAlignLeftCenter&&&'.Select&X,&3&&&'.CellAlignment&=&flexAlignLeftCenter&&&If&SelRow&&&1&And&SelCol&&&0&Then&.Select&SelRow,&SelColEnd&WithExit&SubErrTransact:&&&&&MsgBox&&你输入的数字过大无法计算!请修改!!!&End&Sub------------------------------------------------将数字转换为大写金额的函数:Function&CurrencyToStr(ByVal&Number&As&Currency)&As&String&&Number&=&Val(Trim(Number))&&If&Number&=&0&Then&CurrencyToStr&=&&&:&Exit&Function&&Dim&str1Ary&As&Variant,&str2Ary&As&Variant&&str1Ary&=&Split(&零&壹&贰&叁&肆&伍&陆&柒&捌&玖&)&&str2Ary&=&Split(&分&角&元&拾&佰&仟&万&拾&佰&仟&亿&拾&佰&仟&万&拾&佰&)&&Dim&a&As&Long,&b&As&Long&&'循环基数&&Dim&tmp1&As&String&&&&&&&&'临时转换&&Dim&tmp2&As&String&&&&&&&&'临时转换结果&&Dim&Point&As&Long&&&&&&&&&'小数点位置&&If&Number&&=&-477#&Or&Number&&=&477#&Then&&&&&Exit&Function&&End&If&&&tmp1&=&Round(Number,&2)&&&tmp1&=&Replace(tmp1,&&-&,&&&)&&'先去掉&-&号&&&Point&=&InStr(tmp1,&&.&)&&&&&&&'取得小数点位置&&&If&Point&=&0&Then&&&&&&'如果有小数点,最大佰万亿&&&&&&b&=&Len(tmp1)&+&2&&&'加2位小数&&&Else&&&&&&b&=&Len(Left(tmp1,&Point&+&1))&&'包括点加2位小数&&&End&If&&&''先将所有数字替换为中文&&&For&a&=&9&To&0&Step&-1&&&&&&&tmp1&=&Replace(Replace(tmp1,&a,&str1Ary(a)),&&.&,&&&)&&&Next&&&For&a&=&1&To&b&&&&&&&b&=&b&-&1&&&&&&&If&Mid(tmp1,&a,&1)&&&&&&&Then&&&&&&&&&&If&b&&&UBound(str2Ary)&Then&Exit&For&&&&&&&&&&tmp2&=&tmp2&&&Mid(tmp1,&a,&1)&&&str2Ary(b)&&&&&&&End&If&&&Next&&&If&tmp2&=&&&&Then&CurrencyToStr&=&&&:&Exit&Function&&&''〓下面为非正式财务算法,可以去掉〓&&&For&a&=&1&To&Len(tmp2)&&&&&&&tmp2&=&Replace(tmp2,&&零亿&,&&亿零&)&&&&&&&tmp2&=&Replace(tmp2,&&零万&,&&万零&)&&&&&&&tmp2&=&Replace(tmp2,&&零仟&,&&零&)&&&&&&&tmp2&=&Replace(tmp2,&&零佰&,&&零&)&&&&&&&tmp2&=&Replace(tmp2,&&零拾&,&&零&)&&&&&&&tmp2&=&Replace(tmp2,&&零元&,&&元&)&&&&&&&tmp2&=&Replace(tmp2,&&零零&,&&零&)&&&&&&&tmp2&=&Replace(tmp2,&&亿万&,&&亿&)&&&Next&&&''〓上面为非正式财务算法,可以去掉〓&&&If&Point&=&1&Then&tmp2&=&&零元&&+&tmp2&&&If&Number&&&0&Then&tmp2&=&&负&&+&tmp2&&&If&Point&=&0&Then&tmp2&=&tmp2&+&&整&&&CurrencyToStr&=&tmp2End&Function━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━Cell&属性的使用:Cell&的作用是给以选定区块的特定的设置值,具体值可参阅相应属性值。语法:Cell(条件准则,&Row1,&Col1,&Row2,&Col2)&=&相应准则值其中的&条件准则&有以下准则常数,根据准则的不同而设置相应准则的值:flexcpAlignment&&&&&&&&对齐方式flexcpBackColor&&&&&&&&背景色flexcpChecked&&&&&&&&&&选择框flexcpCustomFormat&&&&&格式设置flexcpData&&&&&&&&&&&&&日期flexcpFloodColor&&&&&&&颜色flexcpFloodPercent&&&&&背景色flexcpFont&&&&&&&&&&&&&字体flexcpFontBold&&&&&&&&&粗体flexcpFontItalic&&&&&&&斜体flexcpFontName&&&&&&&&&字体名flexcpFontSize&&&&&&&&&字体大小flexcpFontStrikethru&&&删除线flexcpFontUnderline&&&&下划线flexcpFontWidth&&&&&&&&字符宽flexcpForeColor&&&&&&&&字符色flexcpHeight&&&&&&&&&&&高flexcpLeft&&&&&&&&&&&&&左flexcpPicture&&&&&&&&&&添加图flexcpPictureAlignment&图对齐flexcpRefresh&&&&&&&&&&刷新flexcpSort&&&&&&&&&&&&&分类flexcpText&&&&&&&&&&&&&字符flexcpTextDisplay&&&&&&显示字符flexcpTextStyle&&&&&&&&文本样式flexcpTop&&&&&&&&&&&&&&返回顶端高,同&RowPos&和&valueMatrix&属性flexcpvalue&&&&&&&&&&&&返回字符值flexcpVariantvalue&&&&&返回字符值flexcpWidth&&&&&&&&&&&&返回单元宽━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━flexSTSum&方法:每行增加小计行[这个方法还不会用]语法:VSG.flexSTSum&常数名,[GroupOn&As&Long],&:标签列[TotalOn&As&Long],&:计算列[Format&As&String],&:格式,例&&$0.00&[BackColor&As&Color],&:Color[ForeColor&As&Color],&:Color[FontBold&As&Boolean],&:False|True[Caption&As&String],&:例&&数&%s&[MatchFrom&As&Integer],&:0|1|2|3[TatalOnly&As&Boolean]&:False|True常数名:常数&&&&&&&&&&&&常数值&&说明flexSTNone&&&&&&0&&&&&&&大纲唯一的,没有合计价值flexSTClear&&&&&1&&&&&&&清除全部的小计flexSTSum&&&&&&&2&&&&&&&总数flexSTPercent&&&3&&&&&&&总数的百分比flexSTCount&&&&&4&&&&&&&行数flexSTAverage&&&5&&&&&&&平均flexSTMax&&&&&&&6&&&&&&&最大的flexSTMin&&&&&&&7&&&&&&&最小的flexSTStd&&&&&&&8&&&&&&&标准偏差flexSTVar&&&&&&&9&&&&&&&方差━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━MousePointer、MouseIcon&鼠标指针的应用:0=flexDefault1=flexArrow2=flexCross3=flexIBeam4=flexIcon5=flexSize6=flexSizeNESW7=flexSizeNS8=flexSizeNWSE9=flexSizeEW10=flexUpArrow11=flexHourglass12=flexNoDrop13=flexArrowHourGlass14=flexArrowQuestion15=flexSizeAll50=flexPointerCopy&&'(&H32)&'拖动带拷贝51=flexPointerMove&&'(&H33)&'拖动52=flexSizeHorz&&'(&H34)&'左右调整53=flexSizeVert&&'(&H35)&'上下调整54=flexHand&&'(&H36)&手型99=flexCustom&'自定义Const&MA&=&&50,51,52,53,54&Dim&xy&As&Integerxy&=&Val(Text1.Text)If&xy&&&15&And&xy&&&&99&And&InStr(MA,&xy)&=&0&Then&xy&=&15VSG1.MousePointer&=&xyIf&xy&=&99&Then&&&VSG1.MouseIcon&=&LoadPicture(&C:/icon/Icon.ico&)End&If━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━单击列头将列互相拖动调换:方法一:VSG1.ExplorerBar&=&flexExMove&&'2&这是最简单的方法了注意这个属性在VB属性表中只设置了0、1、2、3、5、7、8种常数值ExplorerBar&属性(value=0|1|2|3|5|7|8):&&0-flexExNone:默认,单击列头选择整列,单击行头选择整行&&1-flexExSort:单击列头可正反排序该列,单击行头选择整行&&2-flexExMove:单击列头可交换列顺序,单击行头选择整行&&3-flexExSortAndMove:具有&1&和&2&的功能&&4:单击列头可正反排序该列并在列头显示相应箭头,单击行头选择整行&&5-flexExSortShow:好像与&4&相同也&&6:具有&2&和&4&的功能&&7-flexExSortShowAndMove:好像与&6&相同也&&8-flexExMoveRows:单击列头选择整列,可拖动行&&9:单击列头可正反排序该列,可拖动行&&10:可拖动行与列&&11:可排序列及拖动行列&&12:可排序列并在列头显示相应箭头,还可拖动行&&13:同&12。&&14:除&12&功能外,可拖动列&&15:同&14。方法二:Private&Sub&VSG1_MouseDown(Button&As&Integer,&Shift&As&Integer,&X&As&Single,&Y&As&Single)&&Dim&r%,&c%&&r&=&VSG1.MouseRow&&c&=&VSG1.MouseCol&&If&r&=&0&And&c&&&0&Then&&&&&&VSG1.Tag&=&c&&&&&&VSG1.Cell(flexcpBackColor,&0,&c)&=&vbYellow&&&&&&VSG1.MousePointer&=&flexPointerMove&&End&IfEnd&SubPrivate&Sub&VSG1_MouseMove(Button&As&Integer,&Shift&As&Integer,&X&As&Single,&Y&As&Single)&&If&Len(VSG1.Tag)&Then&&&&&&Dim&r%,&c%,&p%&&&&&&r&=&VSG1.MouseRow&&&&&&c&=&VSG1.MouseCol&&&&&&If&r&=&0&And&c&&&0&Then&p&=&flexPointerMove&&&&&&If&VSG1.MousePointer&&&&p&Then&VSG1.MousePointer&=&p&&End&IfEnd&SubPrivate&Sub&VSG1_MouseUp(Button&As&Integer,&Shift&As&Integer,&X&As&Single,&Y&As&Single)&&If&Len(VSG1.Tag)&Then&&&&&&Dim&r%,&c%,&target%&&&&&&target&=&VSG1.Tag&&&&&&VSG1.Cell(flexcpBackColor,&0,&target)&=&0&&&&&&VSG1.Tag&=&&&&&&&&&VSG1.MousePointer&=&0&&&&&&r&=&VSG1.MouseRow&&&&&&c&=&VSG1.MouseCol&&&&&&If&r&=&0&And&c&&&0&And&c&&&&target&Then&&&&&&&&&&VSG1.ColPosition(target)&=&c&&&&&&End&If&&End&IfEnd&Sub━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━VSFlexString控件属性一览表CaseSensitive&&&&&&&&???Error&&&&&&&&&&&&&&&&失败时取得错误信息Index&&&&&&&&&&&&&&&&索引MatchCount&&&&&&&&&&&取得与检索条件相一致的字符串数量MatchIndex&&&&&&&&&&&设定与检索条件相一致的字符串的索引MatchLength&&&&&&&&&&取得与检索条件相一致的字符串长度MatchStart&&&&&&&&&&&取得与检索条件相一致的字符串起始位置MatchString&&&&&&&&&&取得与检索条件相一致的字符串NameObjectParentPattern&&&&&&&&&&&&&&设定检索条件Replace&&&&&&&&&&&&&&设定置换字符串Soundex&&&&&&&&&&&&&&取得代表当前检索字符的声音代码TagTagCount&&&&&&&&&&&&&取得与检索条件相一致的标签数量TagIndex&&&&&&&&&&&&&在多个标签情况下,设定/取得与检索条件相一致的标签索引TagLength&&&&&&&&&&&&取得与检索条件相一致的标签长度TagStart&&&&&&&&&&&&&取得与检索条件相一致的标签起始位置TagString&&&&&&&&&&&&取得与检索条件相一致的标签的字符串Text&&&&&&&&&&&&&&&&&设定成为检索对象Version&&&&&&&&&&&&&&取得FlexString的版本号--------------------------------------------------------&&MSFlexGrid与VSFlexGrid的单元格合并例子:&Private&Sub&Form_Load()Dim&i&As&LongWith&fg&&.WordWrap&=&True&&.Rows&=&6&&.Cols&=&6&&.FixedRows&=&2&&.FixedCols&=&0&&.ColWidth(0)&=&1500&&.RowHeight(0)&=&300&&.RowHeight(1)&=&300&&.TextMatrix(1,&1)&=&&进货&&&.TextMatrix(1,&2)&=&&销售&&&.TextMatrix(1,&3)&=&&退货&&&.TextMatrix(1,&4)&=&&结存&&&&&For&i&=&1&To&.Rows&-&1&&&&.RowHeight(i)&=&300&&'设置行高&&Next&i&&For&i&=&0&To&1&&&.TextMatrix(i,&0)&=&&上月&&&&vbCrLf&&&&结存数量&&&&&&&&&&'//换行&&&.FixedAlignment(0)&=&4&&Next&i&&For&i&=&0&To&1&&&.TextMatrix(i,&5)&=&&月末结存&&&&.FixedAlignment(5)&=&4&&Next&i&&For&i&=&1&To&4&&&&.TextMatrix(0,&i)&=&&本月进销存数量&&&&&.ColAlignment(i)&=&4&&Next&i&&&&.MergeCells&=&flexMergeFree'&&.MergeCells&=&flexMergeFixedOnly&&.MergeCol(0)&=&True&&.MergeRow(0)&=&True&&.MergeCol(5)&=&TrueEnd&With&End&Sub请问:如何使用&VSFlexGrid&Pro&分级显示和存取数据库中的数据。类似于《让&TreeView&支持无限级分类》帖子中所介绍的使用树形控件显示和存取数据库的数据。Dim&cn&as&New&ADODB.RecordsetDim&rs&As&New&ADODB.RecordsetDim&lngY&As&LongDim&intT&As&Integer&cn.open&&............&rs.Open&&select&系统编号&from&test&order&by&系统编号&,&cnWith&VSFlexGrid1&&&&Set&.DataSource&=&rs&&&&&&&&.RowOutlineLevel(1)&=&1&&&&&&&&.IsSubtotal(1)&=&True&&&&&&&&For&lngY&=&1&To&.Rows&-&1&&&&&&&&intT&=&Len(.TextMatrix(lngY,&0))&-&Len(Replace(.TextMatrix(lngY,&0),&&.&,&&&))&&&&&&&&.RowOutlineLevel(lngY)&=&intT&&&&&&&&.IsSubtotal(lngY)&=&True&&&&Next&&&&.OutlineCol&=&0&&&&.OutlineBar&=&flexOutlineBarSimpleLeaf&&&&End&With&&&Set&VSFlexGrid1.DataSource&=&Rs'这一步一定要有,With&VSFlexGrid1&&&&&&&&&&&.DataRefresh&&&&&&&&&&&&&&&&&&&&&&.Sort&=&flexSortGenericDescending'排序&&&&&&&&&End&With&
参考知识库
* 以上用户言论只代表其个人观点,不代表CSDN网站的观点或立场
访问:126207次
积分:1595
积分:1595
排名:第18320名
原创:23篇
转载:41篇
(1)(3)(1)(2)(4)(2)(5)(3)(6)(3)(6)(2)(1)(2)(2)(6)(15)

我要回帖

更多关于 flex tree右键菜单 的文章

 

随机推荐