重庆分公司,新征程启航
为企业提供网站建设、域名注册、服务器等服务
您只要会操作单元格中的数据自然就会了如下:Public Class Form1 Dim conn As Data.OleDb.OleDbConnection
铁西ssl适用于网站、小程序/APP、API接口等需要进行数据传输应用场景,ssl证书未来市场广阔!成为创新互联建站的ssl证书销售渠道,可以享受市场价格4-6折优惠!如果有意向欢迎电话联系或者加微信:13518219792(备注:SSL证书合作)期待与您的合作!
Dim da As Data.OleDb.OleDbDataAdapter
Dim ds As Data.DataSet Private Sub Form1_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
DataGridView1.AllowUserToOrderColumns = False
conn = New OleDb.OleDbConnection( Provider=Microsoft.Jet.OleDb.4.0;Data Source=D:\data.mdb ) 假设表中有两项: price 和 quaty
conn.Open()
da = New OleDb.OleDbDataAdapter( SELECT * FROM 表1 , conn)
ds = New Data.DataSet
da.Fill(ds)
conn.Close()
DataGridView1.DataSource = ds.Tables(0)
DataGridView1.Columns.Add( sum , sum ) 加入一项 sum
For i As Int32 = 0 To DataGridView1.Rows.Count - 1
DataGridView1.Rows(i).Cells(2).Value = DataGridView1.Rows(i).Cells(0).Value * DataGridView1.Rows(i).Cells(1).Value 把前两项的数据相乘,放到第三项中
Next
End Sub End Class
Private Sub DataGridView1_DoubleClick(ByVal sender As Object, ByVal e As System.EventArgs) Handles DataGridView1.DoubleClick
Dim b1
b1 = DataGridView1.CurrentCell.Value
End Sub
双击DataGridView1表格时b1就是该格子的值
using
Microsoft.Office.Interop.Excel;
using
Excel
=
Microsoft.Office.Interop.Excel;
Excel.Application
myExcel
=
new
Excel.Application();
Excel.Workbook
excelWorkbook
=
null;//一个Excel文件
Excel.Worksheet
excelSheet
=
null;
myExcel.Application.Workbooks.Open(@"d:\test.xlsx");//你要打开的excel文件路径
//让Excel文件可见
myExcel.Visible
=
true;
excelWorkbook
=
myExcel.ActiveWorkbook;//给worksheect对象添加选择事件:
workSheet.SelectionChange+=excelSheet_SelectionChange;
excelSheet
=
(Excel.Worksheet)excelWorkbook.ActiveSheet;
//重写事件逻辑
private
void
excelSheet_SelectionChange(Range
range)
{
MessageBox.Show("you
select
"+Target.Address);
}