如何在文本框前面添加datagridview [英] how to bring datagridview in front of text box
本文介绍了如何在文本框前面添加datagridview的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我有一个有很多文本框的表单。我还在表单上有一个datagridview,它在表单加载时隐藏了
,但是当在一个文本框txtsurname中输入一个值时它变得可见。
问题是当datagridview变得可见,文本框总是在它的前面。
如何让datagridview进入文本框前面。
请帮帮我
//代码///
i have a form which have many textboxes. i also have a datagridview on the form which is hiding
when the form loads but it becomes visible when a value is entered in one textbox txtsurname.
the problem is when the datagridview becomes visible, the textboxs are always infront of it.
how do i make the datagridview to come in front of the textboxs.
please help me
//codes///
SqlConnection conn = new SqlConnection(ConfigurationSettings.AppSettings["ConnectionString"]);
string strConn = "Data Source=USER-PC;Initial Catalog=PIWCDB;User ID=sa;Password=mike";
string strSQL = "select Dedicationid, Surname, Othername from tblDedication where surname LIKE '" + txtSurname.Text + "%" + "' order by Surname";
//conn.Open();
SqlDataAdapter dataAdapter = new SqlDataAdapter(strSQL, strConn);
SqlCommandBuilder commandBuilder = new SqlCommandBuilder(dataAdapter);
// Populate a new data table and bind it to the BindingSource.
DataTable table = new DataTable();
table.Locale = System.Globalization.CultureInfo.InvariantCulture;
dataAdapter.Fill(table);
string expression = "[Dedicationid] like '%" + this.txtDedicationno.Text + "%'";
DataRow[] filteredRows = table.Select(expression);
if (filteredRows.Any())
{
table = filteredRows.CopyToDataTable();
this.dgvSearchname.Visible = true;
this.dgvSearchname.BringToFront();
}
else
{
dgvSearchname.Visible = false;
}
// you can make it grid readonly.
dgvSearchname.ReadOnly = true;
dgvSearchname.DataSource = table;
推荐答案
目前尚不清楚..
如果我正确,那么只需在页面加载时将网格显示为false,然后执行代码(根据数据库显示隐藏网格)
It's not clear..
if i am getting right then just make your grid visible false on page load & then execute your code(Show hide grid according result from data base)
这篇关于如何在文本框前面添加datagridview的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文