您只要會操作單元格中的數(shù)據(jù)自然就會了如下:Public Class Form1 Dim conn As Data.OleDb.OleDbConnection
鐵西ssl適用于網(wǎng)站、小程序/APP、API接口等需要進(jìn)行數(shù)據(jù)傳輸應(yīng)用場景,ssl證書未來市場廣闊!成為創(chuàng)新互聯(lián)建站的ssl證書銷售渠道,可以享受市場價格4-6折優(yōu)惠!如果有意向歡迎電話聯(lián)系或者加微信: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 ) 假設(shè)表中有兩項(xiàng): 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 ) 加入一項(xiàng) 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 把前兩項(xiàng)的數(shù)據(jù)相乘,放到第三項(xiàng)中
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);
}