Excelファイルからデータのセルを配置し、それをdatagridviewセルに書き込むプログラムがあります。ただし、データのセルを1つだけ書き込もうとしているので、Excelファイルから単純なテキストボックスにデータを書き込む方が良いと思います。
単純なテキスト ボックスを Excel ファイルと接続する方法がわかりません。どうすればこれを達成できるかについて誰かが提案をしてくれたら、私はそれを大いに感謝します。
以下は、私のデータグリッドビューを操作するための現在のコードです。
'This code sample here uses a for next loop to match the excel column and rows up with the datagridview's rows and columns.
Dim rowindex As Integer
Dim columnindex As Integer
For rowindex = 1 To DataGridView3.RowCount
For columnindex = 1 To DataGridView3.ColumnCount
objworksheet3.Cells(rowindex + 3, columnindex + 1) = DataGridView3(columnindex - 1, rowindex - 1).Value
Next
Next
'This code uses the oledatadapter to pull only the cells that I want from the excel file to populate the datagridview cell.
MyCommand3 = New OleDbDataAdapter("select * from [myWorksheet$B3:B4]", MyConnection)
ds3 = New System.Data.DataSet()
MyCommand3.Fill(ds3)