重庆分公司,新征程启航

为企业提供网站建设、域名注册、服务器等服务

vb点虐 界面显示表格的简单介绍

vb点虐 怎么使用表格控件?

DataGridView控件,放一个DataGridView1和Button1到窗体,下面是按钮下代码

创新互联建站专注于望都网站建设服务及定制,我们拥有丰富的企业做网站经验。 热诚为您提供望都营销型网站建设,望都网站制作、望都网页设计、望都网站官网定制、微信小程序开发服务,打造望都网络公司原创品牌,更为您提供望都网站排名全网营销落地服务。

Private Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click

Me.DataGridView1.AllowUserToAddRows = False

DataGridView1.RowTemplate.Height = 200

DataGridView1.AutoSizeRowsMode = DataGridViewAutoSizeRowsMode.None

For i = 1 To 3

Me.DataGridView1.Columns.Add("列" i.ToString, "列" i.ToString)

Me.DataGridView1.Rows.Add()

Next

Me.DataGridView1.Columns(0).Width = 100

Me.DataGridView1.Columns(1).Width = 500

Me.DataGridView1.Columns(0).Width = 300

End Sub

'自己设置相关需要的属性即可

怎么在VB窗体里显示一个EXCEL工作表.然后

1、调用excel对象打开工作表;

Dim oe As New Excel.Application

Dim ow As Workbook

Dim os As Worksheet

Set ow = oe.Workbooks.Add

Set os = ow.Worksheets(1)

oe.Visible = True

2、取消excel窗体的标题栏、菜单栏、工具栏;

For Each bar In Application.CommandBars

If Not bar.BuiltIn And Not bar.Visible Then bar.Delete

Next

Application.CommandBars("Worksheet Menu Bar").Position = msoBarFloating

Application.CommandBars("Worksheet Menu Bar").Left = -Application.CommandBars("Worksheet Menu Bar").Width + 1

Application.CommandBars("Worksheet Menu Bar").Top = -Application.CommandBars("Worksheet Menu Bar").Height + 1

3、将excel窗体设置为某窗体的"子窗体",调整大小并放在合适位置

Dim IStyle As Long

IStyle = GetWindowLong(hwnd, GWL_STYLE)

IStyle = IStyle And Not WS_CAPTION And Not WS_EX_APPWINDOW

SetWindowLong hwnd, GWL_STYLE, IStyle

ShowWindow hwnd, SW_SHOW

DrawMenuBar hwnd

SetParent hwnd, Form1.hwnd

vb点虐 将excel中数据显示到软件界面

给你看一段我的代码

Public xlApp As Excel.Application

Public xlBook As Excel.Workbook

Public xlSheet As Excel.Worksheet

xlApp = CreateObject("Excel.Application") '创建EXCEL对象

xlBook = xlApp.Workbooks.Open(OpenFileDialog1.FileName) '打开已经存在的EXCEL工件簿文件

xlSheet = xlBook.Worksheets(xlBook.Sheets(1).name) '读取excel

'****************************读取excel数据,显示在数据表上****************************************

DataGridView1.Rows.Clear() '清空记录

For i = 5 To 19

If xlSheet.Cells(i, 1).value "" Then

DataGridView1.Rows.Add(xlSheet.Cells(2, 9).value, xlSheet.Cells(i, 1).value, xlSheet.Cells(2, 2).value, xlSheet.Cells(2, 7).value, xlSheet.Cells(2, 4).value, CDate(DateTimePicker1.Value), "", xlSheet.Cells(i, 5).value, Combo_CZZ.Text, Combo_MacName.Text, "", xlSheet.Cells(1, 3).value, xlSheet.Cells(1, 6).value, "", Combo_BanCi.Text, "")

End If

Next


当前标题:vb点虐 界面显示表格的简单介绍
当前链接:http://cqcxhl.com/article/ddshhpo.html

其他资讯

在线咨询
服务热线
服务热线:028-86922220
TOP