ここに私がフォローしてきたことの背景があります。
http://www.homeandlearn.co.uk/csharp/csharp_s12p9.html
これは、データベースの最後または最初のレコードに移動します。ID番号をテキストボックスに入力して、ユーザーが必要とするアクセスデータベースのレコードにスキップしたいのですが、正しい行がテキストボックスに入れられます。
上記のウェブサイトからこのコードを使用できると思います。上記のWebサイトから他のすべてを実装しました。
グローバル変数
int inc = 0;
後で [スキップ] ボタンで呼び出すナビゲート レコード
private void NavigateRecords()
{
DataRow dRow = ds1.Tables["Laptops"].Rows[inc];
txtMaker.Text = ds1.Tables["Laptops"].Rows[inc].ItemArray.GetValue(1).ToString();
txtModel.Text = ds1.Tables["Laptops"].Rows[inc].ItemArray.GetValue(2).ToString();
txtPrice.Text = ds1.Tables["Laptops"].Rows[inc].ItemArray.GetValue(3).ToString();
txtBids.Text = ds1.Tables["Laptops"].Rows[inc].ItemArray.GetValue(4).ToString();
txtScreen.Text = ds1.Tables["Laptops"].Rows[inc].ItemArray.GetValue(5).ToString();
txtCPU.Text = ds1.Tables["Laptops"].Rows[inc].ItemArray.GetValue(6).ToString();
txtMemory.Text = ds1.Tables["Laptops"].Rows[inc].ItemArray.GetValue(7).ToString();
txtHD.Text = ds1.Tables["Laptops"].Rows[inc].ItemArray.GetValue(8).ToString();
picLaptops.Image = Image.FromFile(ds1.Tables["Laptops"].Rows[inc].ItemArray.GetValue(9).ToString());
}
これまでのスキップボタン...
private void btnSkip_Click(object sender, EventArgs e)
{
NavigateRecords();
}
これを行うのは私には難しいです。やりたいことはわかっているが、それを行うための技術的スキルが不足している。とてもイライラします。どうすればいいのかわかりません。
誰かがそれを解決してコードを見せてくれれば、それを理解して他の場所で使用できます。
これが役立つ場合に次のレコードに移動するための次のボタンの例を次に示します。
private void btnNext_Click(object sender, EventArgs e)
{
if (inc != MaxRows - 1)
{
inc++;
NavigateRecords();
}
else
{
MessageBox.Show("You have reached the end of available items", "End of Available Items", MessageBoxButtons.OK, MessageBoxIcon.Information);
}
}