私はAccessデータベースからいくつかのレコードを抽出するC#でコードを作成しますが、ボタンのクリックに依存して次の繰り返しに行く必要があります。私はいくつかのスレッドやタスクを試しましたが、私はそれを見てクリック可能にする必要があるUIをブロックしたので、うまくいきませんでした。ボタンが押されるまで無限ループのようにUIを作成する
bool nextClick = false ;
while (readerSelect.Read())
{
// show the correct panel
if (string.Compare(readerSelect[2].ToString(), "P1") == 0)
{
// panel with type 1
textBoxP1Text1.Text = readerSelect[3].ToString();
textBoxP1Text2.Text = readerSelect[4].ToString();
pictureBoxP1Image.ImageLocation = readerSelect[6].ToString();
}
else
{
// panel with type 2
textBoxP1Text2.Text = readerSelect[5].ToString();
}
//this while need to be kind of infinite so the interation can't be processed and
//so when i need to change iteration i click the buttonNext
while (!nextClick) {
startWhile:;
MethodInvoker mi = delegate() {
if (nextClick)
{
Application.DoEvents();
// System.Windows.Forms.Application.Run();
}
};
this.Invoke(mi);
//break;
goto startWhile;
}
private void buttonNext_Click(object sender, EventArgs e)
{
// click on the next button
nextClick = true;
}
クリック後に次の項目に移動する必要がある場合は、whileループを使用しないでください。各クリックで1つだけを実行してください。 – Milney
これは、私たちの接続に大きな影響を与えます貧しいですが、お返事ありがとうございます –
「あなたの接続に大きな影響を与える」とはどういう意味ですか?それはちょうど間違っている。あなたが今やってやっているやり方は、そこにたくさんの記録があることだけを読むことになります。あなたは間違っています。あなたが最初のポイントとしてそれをよりよく理解するまで、DataReaderドキュメントを読むことをお勧めします。 – Milney