Click here to Skip to main content
15,894,540 members
Home / Discussions / C#
   

C#

 
GeneralRe: threads Pin
Richard Deeming7-Aug-18 3:48
mveRichard Deeming7-Aug-18 3:48 
QuestionLG Smart TV webos 3.0 .net framework client development Pin
impeham6-Aug-18 12:05
impeham6-Aug-18 12:05 
AnswerRe: LG Smart TV webos 3.0 .net framework client development Pin
Simon_Whale7-Aug-18 4:22
Simon_Whale7-Aug-18 4:22 
QuestionHow do you color cell of the listview ? Pin
Member 24584675-Aug-18 17:51
Member 24584675-Aug-18 17:51 
AnswerRe: How do you color cell of the listview ? Pin
Mycroft Holmes5-Aug-18 19:43
professionalMycroft Holmes5-Aug-18 19:43 
AnswerRe: How do you color cell of the listview ? Pin
OriginalGriff5-Aug-18 20:27
mveOriginalGriff5-Aug-18 20:27 
GeneralRe: How do you color cell of the listview ? Pin
Member 24584678-Aug-18 15:33
Member 24584678-Aug-18 15:33 
QuestionSelectedIndex doesn't work with the SelectionChanged event handler but it works with the ButtonClick event handler. Pin
Member 138463763-Aug-18 22:32
Member 138463763-Aug-18 22:32 
I have a problem with making a simple SelectedIndex to work with the SelectionChanged.
The same piece of code worked perfectly well with the button click as the event handler but it doesn't work with the selection changed...

All I want is to have a ComboBox with a default value selected,
TextBox displaying this value below, and changing every time I change the selection.


<ComboBox  x:Name="BetonCombo" Margin="5"  Grid.Column="0" Padding="2" HorizontalAlignment="Center" Width="150" SelectedValuePath="Content" SelectionChanged="BetonCombo_SelectionChanged">
    <ComboBoxItem>C16/20 (B20)</ComboBoxItem>
    <ComboBoxItem>C20/25 (B25)</ComboBoxItem>
    <ComboBoxItem>C25/30 (B30)</ComboBoxItem>
    <ComboBoxItem IsSelected="True">C30/37 (B37)</ComboBoxItem>
    <ComboBoxItem>C35/45 (B45)</ComboBoxItem>
</ComboBox>


private void BetonCombo_SelectionChanged(object sender, SelectionChangedEventArgs e)
       {

           int mBetonIndex = BetonCombo.SelectedIndex;

               double[] Fck = new double[5];
               Fck[0] = 20;
               Fck[1] = 25;
               Fck[2] = 30;
               Fck[3] = 37;
               Fck[4] = 45;

               double mFck = Fck[mBetonIndex];
               fck.Text = mFck.ToString() + " MPa";
       }


I am getting this exception
System.NullReferenceException: 'Object reference not set to an instance of an object.'
with the last line of code highlighted as the problem (fck.Text = mFck.ToString() + " MPa";).

I don't understand how I could get a null reference if the exact same code worked perfectly fine in the button click event handler? Do I need to set a default value of the ComboBox differently than with a IsSelected=true?
AnswerRe: SelectedIndex doesn't work with the SelectionChanged event handler but it works with the ButtonClick event handler. Pin
OriginalGriff3-Aug-18 22:40
mveOriginalGriff3-Aug-18 22:40 
GeneralRe: SelectedIndex doesn't work with the SelectionChanged event handler but it works with the ButtonClick event handler. Pin
Member 138463763-Aug-18 23:11
Member 138463763-Aug-18 23:11 
GeneralRe: SelectedIndex doesn't work with the SelectionChanged event handler but it works with the ButtonClick event handler. Pin
OriginalGriff3-Aug-18 23:22
mveOriginalGriff3-Aug-18 23:22 
QuestionRe: SelectedIndex doesn't work with the SelectionChanged event handler but it works with the ButtonClick event handler. Pin
Eddy Vluggen3-Aug-18 23:41
professionalEddy Vluggen3-Aug-18 23:41 
AnswerRe: SelectedIndex doesn't work with the SelectionChanged event handler but it works with the ButtonClick event handler. Pin
OriginalGriff4-Aug-18 0:04
mveOriginalGriff4-Aug-18 0:04 
GeneralRe: SelectedIndex doesn't work with the SelectionChanged event handler but it works with the ButtonClick event handler. Pin
Eddy Vluggen4-Aug-18 0:17
professionalEddy Vluggen4-Aug-18 0:17 
AnswerRe: SelectedIndex doesn't work with the SelectionChanged event handler but it works with the ButtonClick event handler. Pin
Member 138463764-Aug-18 2:21
Member 138463764-Aug-18 2:21 
GeneralRe: SelectedIndex doesn't work with the SelectionChanged event handler but it works with the ButtonClick event handler. Pin
OriginalGriff4-Aug-18 2:28
mveOriginalGriff4-Aug-18 2:28 
GeneralRe: SelectedIndex doesn't work with the SelectionChanged event handler but it works with the ButtonClick event handler. Pin
Member 138463764-Aug-18 3:18
Member 138463764-Aug-18 3:18 
GeneralRe: SelectedIndex doesn't work with the SelectionChanged event handler but it works with the ButtonClick event handler. Pin
OriginalGriff4-Aug-18 3:30
mveOriginalGriff4-Aug-18 3:30 
GeneralRe: SelectedIndex doesn't work with the SelectionChanged event handler but it works with the ButtonClick event handler. Pin
Member 138463764-Aug-18 11:39
Member 138463764-Aug-18 11:39 
GeneralRe: SelectedIndex doesn't work with the SelectionChanged event handler but it works with the ButtonClick event handler. Pin
OriginalGriff4-Aug-18 21:52
mveOriginalGriff4-Aug-18 21:52 
GeneralRe: SelectedIndex doesn't work with the SelectionChanged event handler but it works with the ButtonClick event handler. Pin
Member 138463765-Aug-18 1:16
Member 138463765-Aug-18 1:16 
GeneralRe: SelectedIndex doesn't work with the SelectionChanged event handler but it works with the ButtonClick event handler. Pin
OriginalGriff5-Aug-18 1:28
mveOriginalGriff5-Aug-18 1:28 
GeneralRe: SelectedIndex doesn't work with the SelectionChanged event handler but it works with the ButtonClick event handler. Pin
Eddy Vluggen5-Aug-18 5:54
professionalEddy Vluggen5-Aug-18 5:54 
GeneralRe: SelectedIndex doesn't work with the SelectionChanged event handler but it works with the ButtonClick event handler. Pin
OriginalGriff5-Aug-18 6:07
mveOriginalGriff5-Aug-18 6:07 
GeneralRe: SelectedIndex doesn't work with the SelectionChanged event handler but it works with the ButtonClick event handler. Pin
Eddy Vluggen5-Aug-18 10:49
professionalEddy Vluggen5-Aug-18 10:49 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.