TECHNOLOGIES
FORUMS
JOBS
BOOKS
EVENTS
INTERVIEWS
Live
MORE
LEARN
Training
CAREER
MEMBERS
VIDEOS
NEWS
BLOGS
Sign Up
Login
No unread comment.
View All Comments
No unread message.
View All Messages
No unread notification.
View All Notifications
Answers
Post
An Article
A Blog
A News
A Video
An EBook
An Interview Question
Ask Question
Forums
Monthly Leaders
Forum guidelines
Violeta Popa
NA
137
163.7k
comboBox doesn't work properly
Apr 6 2013 3:49 AM
Hello :) I have a datagridview in form 1 and in form 2 a comboBox. I want to select an item from the comboBox depending on a cell from dgv. Here's the code
SqlConnection conn = new SqlConnection();
conn.ConnectionString = "..";
conn.Open();
Acasa main = (Acasa)Application.OpenForms["Acasa"];
DataGridView dgv = main.categdaGridView;
int i = dgv.CurrentRow.Index;
textBox1.Text = dgv.Rows[i].Cells[1].Value.ToString();
textBox3.Text = dgv.Rows[i].Cells[3].Value.ToString();
comboBox1.SelectedItem =
dgv.Rows[i].Cells[2].Value.ToString();
conn.Close();
but the comboBox doesn't select nothing :| if i do comboBox1.SelectedItem="discount" it works, and i checked
dgv.Rows[i].Cells[2].Value.ToString(); has the same value(discount). Does anybody know what could cause it? Thank u very much.
Reply
Answers (
7
)
Defining function to return a string value
what is the Code for Forgot password in asp.net with c#??