DataGridView不显示DataTable内容

时间:2012-10-28 02:08:20

标签: datagridview datatable

我有两个TextBox;

  1. FirmName
  2. 客户名称
  3. 但是当我搜索FIrmBAsed信息时,我会在DataGridView1 DataTAble1 FirmName中获取Prpoer Reslut但是当我正在取消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(); } 中显示...而是看不到......我可能知道原因......

    代码:

    {{1}}

0 个答案:

没有答案