当前位置: 网学 > 编程文档 > VB > 正文

用VB实现类似电子表格的数据录入

来源:Http://myeducs.cn 联系QQ:点击这里给我发消息 作者: 用户投稿 来源: 网络 发布时间: 12/10/16
下载{$ArticleTitle}原创论文样式
d1.SelStartRow = 1  ''网格中单元格的列、行初始位置

Grid1.LeftCol = 1

Grid1.TopRow = 1   ''网格中左上角的列、行初始位置

End Sub

Private Sub Grid1_MouseDown(Button As Integer,

        Shift As Integer, X As Single, Y As Single)

Grid1.Col = Grid1.SelStartCol

Grid1.Row = Grid1.SelStartRow

Text1.Text = Grid1.Text

colnum = Grid1.Col - Grid1.LeftCol + 1

rownum = Grid1.Row - Grid1.TopRow + 1

Text1.Left = Grid1.Left + (Grid1.ColWidth(0)

         + Grid1.GridLineWidth * 12) * colnum

Text1.Top = Grid1.Top + (Grid1.RowHeight(0)

         + Grid1.GridLineWidth * 12) * rownum

End Sub

Private Sub Grid1_MouseUp(Button As Integer,

         Shift As Integer, X As Single, Y As Single)

Text1.SetFocus

End Sub

Private Sub HScroll1_Change()

startcol = Grid1.LeftCol

Grid1.LeftCol = HScroll1.Value

Grid1.SelStartCol = Grid1.SelStartCol

           + Grid1.LeftCol - startcol

Grid1.Col = Grid1.SelStartCol

Text1.Text = Grid1.Text

End Sub

Private Sub Text1_Change()

Grid1.Text = Text1.Text

End Sub

Private Sub Text1_KeyDown(KeyCode

         As Integer, Shift As Integer)

Select Case KeyCode

Case 38  '' 光 标 向 上

Grid1.Text = Text1.Text

If Grid1.SelStartRow <2 Then If Grid1.TopRow> 1 Then

      VScroll1.Value = VScroll1.Value - 1

   Else

      Grid1.SelStartRow = 1

   End If

Else

   If Grid1.TopRow = Grid1.SelStartRow Then

      VScroll1.Value = VScroll1.Value - 1

   Else

      Grid1.SelStartRow = Grid1.SelStartRow - 1

   End If

End If

Grid1.Col = Grid1.SelStartCol

Grid1.Row = Grid1.SelStartRow

colnum = Grid1.Col - Grid1.LeftCol + 1

rownum = Grid1.Row - Grid1.TopRow + 1

Text1.Text = Grid1.Text

Text1.Left = Grid1.Left + (Grid1.ColWidth(0)

          + Grid1.GridLineWidth * 12) * colnum

Text1.Top = Grid1.Top + (Grid1.RowHeight(0)

          + Grid1.GridLineWidth * 12) * rownum

Exit Sub

Case 40  '' 光 标 向 下

Grid1.Text = Text1.Text

If Grid1.SelStartRow > inputrownum - 1 Then

   If Grid1.TopRow <Grid1.Rows inputrownum Then VScroll1.Value="VScroll1.Value" + 1 Else If VScroll1.Value="VScroll1.Max" And Grid1.SelStartRow < Grid1.Rows 1 Then Grid1.SelStartRow="Grid1.SelStartRow" + 1 Else Grid1.SelStartRow="Grid1.Rows" 1 End If End If Else If Grid1.TopRow="Grid1.SelStartRow" inputrownum Then VScroll1.Value="VScroll1.Value" + 1 Else Grid1.SelStartRow="Grid1.SelStartRow" + 1 End If End If Grid1.Col="Grid1.SelStartCol" Grid1.Row="Gri

网学推荐

免费论文

原创论文

浏览:
设为首页 | 加入收藏 | 论文首页 | 论文专题 | 设计下载 | 网学软件 | 论文模板 | 论文资源 | 程序设计 | 关于网学 | 站内搜索 | 网学留言 | 友情链接 | 资料中心
版权所有 QQ:3710167 邮箱:3710167@qq.com 网学网 [Myeducs.cn] 您电脑的分辨率是 像素
Copyright 2008-2015 myeducs.Cn www.myeducs.Cn All Rights Reserved
湘ICP备09003080号