hello friends,

i m developing an windows application in VS2010 using Visual C# and MS Sql 2008 R2.
i have a form consisting of datagridview and a Combobox.
Name of DataGridView is "dgAccount" having three columns "Name","RollNo","City".
Name of Combobox is "cboName".

The Name of my DataBase is "dbAC".
The Name Of Table is "tblAc",having three columns "Name","RollNo","City"
The Name of Dataset is "dsAc"

I have have accomplished 2 tasks out of 3 and want yours help for completing 3rd task
the 2 tasks completed are
1)I Populated all Values from "Name" Column of "tblAc" into combobox "cboName".
2)My datagridview is displaying data from table "tblAc" having three columns "Name","RollNo","City".

now 3rd task - i am trying to navigate to particular record in datagrid view based upon the item selected from combobox
i.e when i select a Name from Combobox my datagridview should navigate to Record having that Name .

Hope my question is clear enough for understanding
Seeking your quick reply

Recommended Answers

All 2 Replies

If you wanna put into edit mode a cell that equals the comboBox selected item, then you can do:

        private void comboBox1_SelectedIndexChanged(object sender, EventArgs e)
            foreach (DataGridViewRow row in dataGridView1.Rows)
                if (row.Cells[0].Value.ToString() == comboBox1.SelectedItem.ToString()) //0 is for 1st column
                    DataGridViewCell cell = row.Cells[0];
                    dataGridView1.CurrentCell = cell;

Thanks Mitja it worked for me thankxx a lot .

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, learning, and sharing knowledge.