2 つの TextBox があります。
- 会社名
- 顧客名
しかし、情報を検索FIrmBAsed
すると Prpoer Reslut がDataGridView1
Fromに表示されるDataTAble1
しかし、コンテンツをすぐにキャンセルすると、行を取得する場所をFirmName
検索しに行くが、表示できない ...というより、表示されない... 原因がわかりますか...CUstome Name
DATABLE1
DataGridView1
コード:
private void txtCustomerName_TextChanged(object sender, EventArgs e)
{
if (txtCustomerName.Text == "")
{
dgvSearchData.Visible = false;
}
else
{
dgvSearchData.Visible = true;
dgvSearchData.Location = new Point(txtCustomerName.Location.X, (txtCustomerName.Location.Y + txtCustomerName.Height));
query = "Select CustomerName,FirmName, Address, City from CustomerMaster WHERE CustomerName LIKE '" + txtCustomerName.Text + "%' ";
dtCustomer.Clear();
dtCustomer = objDBConnection.fSelect(query);
**dgvSearchData.DataSource = dtCustomer;**
if (dgvSearchData.Rows.Count > 0) dgvSearchData.Rows[0].Selected = false;
if (dgvSearchData.Rows.Count == 1) dgvSearchData.Rows[0].Selected = true;
if (dgvSearchData.Rows.Count > 0)
dgvSearchData.Height = (dgvSearchData.Rows.Count) * 23;
if (dgvSearchData.Height >= new frmRetailBill().Size.Height)
dgvSearchData.Height = new frmRetailBill().Size.Height - 20;
for (int i = 1; i < dgvSearchData.Columns.Count; i++)
dgvSearchData.Columns[i].Visible = false;
}
}
public void fillCusotmerData()
{
for (int i = 1; i < dgvSearchData.Columns.Count; i++)
dgvSearchData.Columns[i].Visible = true;
txtCustomerName.Text = dgvSearchData.SelectedRows[0].Cells["CustomerName"].Value.ToString();
txtFirmName.Text = dgvSearchData.SelectedRows[0].Cells["FirmName"].Value.ToString();
txtAddress.Text = dgvSearchData.SelectedRows[0].Cells["Address"].Value.ToString() + " " + dgvSearchData.SelectedRows[0].Cells["City"].Value.ToString();
dgvSearchData.Visible = false;
txtPartNumber.Focus();
}