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
Gustavo
NA
1.3k
454.2k
How Do I: Show the Selected Item on a ComboBox in my Sample?
May 24 2010 4:44 PM
Hello:
Below is my code. I do load the new value into the ComboBox, but I dont know how to have it show on the Form. The values that I load in the textBox is fine, but the ComboBox does not show what is loaded. Can someone tell me what I need to do on the line:
//comboBox1.SelectedItem = TheOriginalValue; ?
private
void
textBox_ID_Validated(
object
sender,
EventArgs
e)
{
Control
TheControlEvent =
this
.GetNextControl(
null
,
true
);
while
(TheControlEvent !=
null
)
{
TheEventType = TheControlEvent.GetType().Name;
TheEventName = TheControlEvent.Name;
TheEventValue = TheControlEvent.Text;
switch
(TheEventType)
{
case
"TextBox"
:
for
(TheRow = 0; TheRow < dataGridViewRecord.Rows.Count - 1; TheRow++)
{
TheColumnValue = dataGridViewRecord.Rows[TheRow].Cells[
"Column"
].Value.ToString();
TheOriginalValue = dataGridViewRecord.Rows[TheRow].Cells[
"TheOriginal"
].Value.ToString();
if
(TheEventName.Substring(7) == TheColumnValue)
{
TheControlEvent.Text = TheOriginalValue;
break
;
}
}
break
;
case
"ComboBox"
:
for
(TheRow = 0; TheRow < dataGridViewRecord.Rows.Count - 1; TheRow++)
{
TheColumnValue = dataGridViewRecord.Rows[TheRow].Cells[
"Column"
].Value.ToString();
TheOriginalValue = dataGridViewRecord.Rows[TheRow].Cells[
"TheOriginal"
].Value.ToString();
if
(TheEventName.Substring(8) == TheColumnValue)
{
TheControlEvent.Text = TheOriginalValue;
//TheControlEvent.Refresh();
//comboBox1.SelectedItem = TheOriginalValue;
// NEEDS WORK TO SHOW: SelectedItem
break
;
}
}
break
;
default
:
break
;
}
TheControlEvent =
this
.GetNextControl(TheControlEvent,
true
);
}
}
Reply
Answers (
6
)
App.config separated from my exec file?
please help me, what is the code ?