|
|
|
如何实现将vsflexgrid中修改的数据反馈到数据库中 |
热 ★★★★ |
|
如何实现将vsflexgrid中修改的数据反馈到数据库中 |
|
作者:闵涛 文章来源:闵涛的学习笔记 点击数:2868 更新时间:2009/4/22 23:09:09 |
|
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 If End 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 If End Sub 或: Private Sub VSG1_RowColChange() If VSG1.Col = 1 Or VSG1.Col = 3 Then SendKeys "{RIGHT}" Else SendKeys "{ENTER}" End If End Sub 或: Private Sub VSG1_RowColChange() If VSG1.Col = 1 Or VSG1.Col = 3 Then VSG1.Editable = flexEDNone Else VSG1.Editable = flexEDKbd VSG1.EditCell ''''自动选择单元内容 VSG1.EditSelStart = 0[选到最前]|1[选到指定]|Len(VSG1.Text)[选到最后] End If End Sub ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ ''''对齐方式(-1标示所有) .ColAlignment(-1) = flexAlignLeftCenter|flexAlignCenterCenter|flexAlignRightCenter 示例1:(最后一行的第3列靠右对齐) VSG1.Select VSG1.Rows - 1, 2 VSG1.CellAlignment = flexAlignRightCenter 示例2: VSG1.Row = VSG1.Rows - 1: VSG1.Col = 1 VSG1.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.Drag VSG1.DragIcon = LoadPicture("D:\Icon.ico") VSG1.DragRow VSG1.RowSel End Sub 或从其它对象拖: Private Sub VSG2_MouseDown(Button As Integer, _ Shift As Integer, X As Single, Y As Single) VSG2.OLEDrag VSG1.OLEDropMode = flexOLEDropAutomatic End Sub ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ Public Sub VSGridCount(Optional SelRow As Long, Optional SelCol As Long) Dim X As Long, i As Long Dim Hj1, Hj2, Hj3 As String Const A1 = -922337203685477#, A2 = 922337203685477# On Error GoTo ErrTransact With 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] [2] [3] [4] [5] 下一页 没有相关教程
|
|
教程录入:mintao 责任编辑:mintao |
|
|
上一篇教程: 用Dede再次大战一个工资管理软件 下一篇教程: 使用分页查询来适应挖掘海量数据的需求 |
|
|
【字体:小 大】【发表评论】【加入收藏】【告诉好友】【打印此文】【关闭窗口】 |
|
注:本站部分文章源于互联网,版权归原作者所有!如有侵权,请原作者与本站联系,本站将立即删除! 本站文章除特别注明外均可转载,但需注明出处! [MinTao学以致用网] |
网友评论:(只显示最新10条。评论内容只代表网友观点,与本站立场无关!) |
|
|
|
|
|
|
|
同类栏目 |
|
|
赞助链接 |
|
|
500 - 内部服务器错误。
|
|
|
|
|
|