LoadItems() 함수를 호출하면 아래 이벤트가 트리거됩니다. 내가 항목을 검색 할 때 처음로드, 그러나 그것은 다시 이벤트를 트리거 다시() 함수 LoadItems를 호출 할 때C++ load inventoryGrid_CellValueChanged에서 함수가 호출되지 않도록하는 방법
void InventoryList::LoadItems()
{
string s = "select * from pos_db.items;";
String^ cmdString = gcnew String(s.c_str());
String^ conString = L"datasource=localhost;port=3306;username=root;password=root";
MySqlConnection^ conDataBase = gcnew MySqlConnection(conString);
MySqlCommand^ cmdDataBase = gcnew MySqlCommand(cmdString, conDataBase);
MySqlDataReader^ myReader;
try
{
conDataBase->Open();
myReader = cmdDataBase->ExecuteReader();
while(myReader->Read())
{
inventoryGrid->Rows->Add();
DataGridViewRow^ row = inventoryGrid->Rows[inventoryGrid->RowCount - 1];
row->Cells["alu"]->Value = myReader->GetString(0);
row->Cells["upc"]->Value = myReader->GetString(1);
row->Cells["vendor"]->Value = myReader->GetString(2);
row->Cells["sku"]->Value = myReader->GetString(3);
row->Cells["description"]->Value = myReader->GetString(4);
row->Cells["size"]->Value = myReader->GetString(5);
row->Cells["color"]->Value = myReader->GetString(6);
row->Cells["price"]->Value = myReader->GetString(7);
row->Cells["cost"]->Value = myReader->GetString(8);
row->Cells["quantity"]->Value = myReader->GetString(9);
}
conDataBase->Close();
}
catch (Exception^ ex)
{
MessageBox::Show(ex->Message);
}
}
private: System::Void inventoryGrid_CellValueChanged(System::Object^ sender, System::Windows::Forms::DataGridViewCellEventArgs^ e)
{
if (inventoryGrid->Visible)
{
UpdateItem(e->RowIndex, inventoryGrid->Columns[e->ColumnIndex]->Name, (String^)inventoryGrid->Rows[e->RowIndex]->Cells[e->ColumnIndex]->Value);
}
}
inventoryGrid-은> 가시가 호출되는 것을에 updateItem() 함수를 유지합니다. 문제는 검색 중에 호출 될 때 DataGridView가 표시되고 UpdateItem() 함수가 호출된다는 것입니다. DataGridView 깜박임을 빨리 보지 않고도이 문제를 어떻게 방지 할 수 있습니까?
특히 어떤 GUI 프레임 워크입니까? downvotes을 피하기 위해 적절하게 (빠른) 귀하의 질문에 태그를 지정하십시오! –
@ args 이벤트 인수는 WinForms 네임 스페이스에 있습니다. –
@DavidYaw이 질문에는 여러 가지 개선 사항이 있습니다 ... –