Click here to Skip to main content
15,949,741 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
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;
Posted
Comments
Karthik_Mahalingam 24-Jan-14 5:16am    
not clear,
pls provide more details..
when the DGV is visible, you need to make the textbox hide ??

1 solution

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)
 
Share this answer
 
Comments
CHill60 27-Jan-14 9:58am    
That is what the OP has said he is doing. But other controls are appearing in front of the DGV when he makes it visible, despite having used .BringToFront
V5709 28-Jan-14 1:56am    
yes, But i am saying to make it invisible in page load it means by default(Not in design, by coding) & not in the function or event so that program will not wait for any other event or function call to hide grid.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900