這是從我的項目之一,從一個DataGridView將數據保存到數據庫中的一段代碼,你應該明白我的意思:
For i = 0 To DG_add_stock.Rows.Count - 1
Dim stock_code As String = CStr(DG_add_stock.Rows(i).Cells("Code").Value)
Dim stock_desc As String = CStr(DG_add_stock.Rows(i).Cells("Description").Value)
Dim qty As String = CStr(DG_add_stock.Rows(i).Cells("Qty").Value)
Dim price As String = CStr(DG_add_stock.Rows(i).Cells("Price").Value)
Dim tax_rate As String = CStr(DG_add_stock.Rows(i).Cells("Tax_Rate").Value)
Dim line_total As String = CStr(DG_add_stock.Rows(i).Cells("Line_Total").Value)
''' Save the data in a database or update existing data
Next
再到顯示的數據:
DG_Maintenance_Stock.Rows.Clear()
''' Get the data from the database
For add_items = 0 To row_count - 1
''' Load values from each row
DG_Maintenance_Stock.Rows.Add(code_list, desc_list, qty_list, tax_rate_list, price_list)
DG_Maintenance_Stock.Sort(maintenance_stock_Code, System.ComponentModel.ListSortDirection.Ascending)
Next
只是從您的標籤猜測,但你用這與Microsoft Access?如果是這樣,您應該使用[tag:ms-access]標籤而不是[tag:access](請參閱後者的使用指南)。 –
我們只能猜測你想做什麼。也許這會做你想做的:'DataGridView.Enabled = False DataGridView.ReadOnly = True' – muffi
你沒有告訴我們*什麼*沒有工作 – Plutonix