Olukayode Oluwole
asked on
How can i get a record from my combobox into a string variable
I have c# application in which i am trying to get records from
a combobox into a string variable.
The combo loads at Form load ( see screen below )
I the tried to select any of the records into a string variable and some how
my string variable instead of having data from the combo has an error statement
about my Model (see error page )
I then tried to use the debugger to find out if the record i selected is somewhere in memory
and indeed it showed up (see debugger output)
How do i get the combo record out to my string variable.
Below is the Script that i am using to select the record from the combo and putting it in a string
variable
[private void glTRANSCurrencyValue_Selec tedIndexCh anged(obje ct sender, EventArgs e)
{
// Setting index to 0 at form load ensure that script below is not processed during combo initial load
if (this.glTRANSCurrencyValue .SelectedI ndex != 0)
{
string phrase = glTRANSCurrencyValue.Selec tedItem.To String();
string[] words = phrase.Split(' ');
int i = 0;
foreach (var word in words)
{
i += 1;
if (i == 1)
{
decimal var1 = Convert.ToDecimal($"{word} ");
glTRANSExchrateValue.Text = Convert.ToString(var1);
}
}
}
}[/code]
How do i get the combo record into the string variable
Thanks
Olukay
a combobox into a string variable.
The combo loads at Form load ( see screen below )
I the tried to select any of the records into a string variable and some how
my string variable instead of having data from the combo has an error statement
about my Model (see error page )
I then tried to use the debugger to find out if the record i selected is somewhere in memory
and indeed it showed up (see debugger output)
How do i get the combo record out to my string variable.
Below is the Script that i am using to select the record from the combo and putting it in a string
variable
[private void glTRANSCurrencyValue_Selec
{
// Setting index to 0 at form load ensure that script below is not processed during combo initial load
if (this.glTRANSCurrencyValue
{
string phrase = glTRANSCurrencyValue.Selec
string[] words = phrase.Split(' ');
int i = 0;
foreach (var word in words)
{
i += 1;
if (i == 1)
{
decimal var1 = Convert.ToDecimal($"{word}
glTRANSExchrateValue.Text = Convert.ToString(var1);
}
}
}
}[/code]
How do i get the combo record into the string variable
Thanks
Olukay
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Hi,
I was out for weekend.
Did you manage to solve it?
ziolko
I was out for weekend.
Did you manage to solve it?
ziolko
ASKER
Yes I did but ran into a different problem . I will post this shortly thanks
ASKER
System.Data.DataRowView selected_row = comboBox1.SelectedItem as System.Data.DataRowView;
textBox1.Text = selected_row["FieldName1"]
but selected_row was null even though I selected a row. See screen below
Did i do anything wrong ??
I will try the second option and get back to you.
But while i try that are you on TeamViewer so we can sort this out in real time
Thanks
Olukay