Click here to Skip to main content
15,905,504 members
Home / Discussions / C#
   

C#

 
GeneralRe: ComboBox not properly adding items Pin
Luc Pattyn19-Apr-08 15:12
sitebuilderLuc Pattyn19-Apr-08 15:12 
GeneralRe: ComboBox not properly adding items Pin
Jordanwb19-Apr-08 15:53
Jordanwb19-Apr-08 15:53 
GeneralRe: ComboBox not properly adding items Pin
Luc Pattyn19-Apr-08 16:09
sitebuilderLuc Pattyn19-Apr-08 16:09 
GeneralRe: ComboBox not properly adding items Pin
Jordanwb19-Apr-08 16:27
Jordanwb19-Apr-08 16:27 
GeneralRe: ComboBox not properly adding items Pin
Luc Pattyn19-Apr-08 22:59
sitebuilderLuc Pattyn19-Apr-08 22:59 
GeneralRe: ComboBox not properly adding items Pin
Jordanwb20-Apr-08 4:09
Jordanwb20-Apr-08 4:09 
GeneralRe: ComboBox not properly adding items Pin
Luc Pattyn20-Apr-08 13:30
sitebuilderLuc Pattyn20-Apr-08 13:30 
GeneralRe: ComboBox not properly adding items [modified] Pin
Jordanwb20-Apr-08 16:07
Jordanwb20-Apr-08 16:07 
Luc Pattyn wrote:
you have a problem in the button click handler, but you don't show its code.
you explain about HashMap but the code you show does not use it.
you had null exceptions but they are gone without any explanation? or are they still present?
are you sure you want to be successful in software development?
start by giving all relevant code, exactly as it is, and all the symptoms, and please
combine them in a single message, to increase the possibility they describe a consistent
situation.


It's hard to have a consistent solution if the program isn't acting consistantly (flashbacks to Java). The HashMap class is irrelevant to the problem. In the Button click event I am no longer getting the NullReferenceException.

Here's the button click event:

<br />
        private void btn_okay_Click(object sender, EventArgs e)<br />
        {<br />
            try<br />
            {<br />
                Category s = (Category)cmb_categories.SelectedItem;<br />
                MessageBox.Show(s.ToString());<br />
            }<br />
            catch (NullReferenceException nre)<br />
            {<br />
                MessageBox.Show(nre.ToString());<br />
            }<br />
        }<br />


What is there to go wrong there on my end? Yesterday cmb_categories.SelectedItem was returning null, now it's not. I get a MessageBox saying "Office" or "Programming" like it should, so that would mean no NullReferenceException. The HashMap returned a proper array of Categories, no nulls whatsoever.

Also in the constructor I added this line directly after "this.cmb_categories.Items.AddRange(categories.ToArray());":

ComboBox.ObjectCollection oj = cmb_categories.Items;

oj.Count said 2, which is correct. I place a breakpoint at the line mentionned above and it reaches that line I hover over oj, then hover over "Non Public Members", then over "innerList" it shows two objects both of type Category, and the proper ToString() method of the two categories were called.

Luc Pattyn wrote:
you explain about HashMap but the code you show does not use it.


Yes I did, check the constructor's parameters. I called it a HashMap because that's what it's called in Java. Until today I learned that C# has one in System.Collections.Generic, it's called a Dictionary.

Luc Pattyn wrote:
are you sure you want to be successful in software development?


Who said I wanted to go into software development? I plan on going into PHP based website design.

Oh BTW, I had a similar problem with a ListBox I believe. I had one form with said ListBox, I had two different classes extend that form. On one form the add worked whereas on one class it did not. In the parent form I had a method to do an invoke to avoid the CrossThreadedCallException. Both child classes used the same method. Then for some reason the second started working for no reason whatsoever. Was that my fault? I've seen this happen dozens of times: code just starts working with everyone scratching their heads.

modified on Sunday, April 20, 2008 10:13 PM

GeneralRe: ComboBox not properly adding items Pin
Luc Pattyn20-Apr-08 16:44
sitebuilderLuc Pattyn20-Apr-08 16:44 
GeneralRe: ComboBox not properly adding items Pin
Jordanwb21-Apr-08 2:46
Jordanwb21-Apr-08 2:46 
Question.NET certification? Pin
YAI19-Apr-08 13:58
YAI19-Apr-08 13:58 
AnswerRe: .NET certification? Pin
leckey19-Apr-08 14:48
leckey19-Apr-08 14:48 
AnswerRe: .NET certification? Pin
Zoltan Balazs19-Apr-08 23:19
Zoltan Balazs19-Apr-08 23:19 
QuestionNeed Help with SendInput for key commands Pin
Luke Dyer19-Apr-08 12:05
Luke Dyer19-Apr-08 12:05 
GeneralRe: Need Help with SendInput for key commands Pin
Dominik Reichl20-Apr-08 2:04
Dominik Reichl20-Apr-08 2:04 
QuestionHow to make AutoGeneration Code tools ? Pin
hdv21219-Apr-08 10:37
hdv21219-Apr-08 10:37 
AnswerRe: How to make AutoGeneration Code tools ? Pin
Mycroft Holmes19-Apr-08 17:31
professionalMycroft Holmes19-Apr-08 17:31 
GeneralDon't show ToolStripMenuItem in Taskbar Pin
Jordanwb19-Apr-08 9:56
Jordanwb19-Apr-08 9:56 
GeneralRe: Don't show ToolStripMenuItem in Taskbar Pin
hostar16-Oct-14 6:31
hostar16-Oct-14 6:31 
GeneralRead/write custom events to XML Pin
xax19-Apr-08 7:43
xax19-Apr-08 7:43 
GeneralRe: Read/write custom events to XML Pin
Guffa19-Apr-08 10:25
Guffa19-Apr-08 10:25 
GeneralRe: Read/write custom events to XML Pin
xax20-Apr-08 9:00
xax20-Apr-08 9:00 
QuestionIP version 6 input control ? Pin
nesaver8519-Apr-08 7:25
nesaver8519-Apr-08 7:25 
GeneralRe: IP version 6 input control ? Pin
Sam Xavier24-Apr-08 21:07
Sam Xavier24-Apr-08 21:07 
Questiondeploy windows service with additional tasks Pin
Knowledgestudent19-Apr-08 7:20
Knowledgestudent19-Apr-08 7:20 

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.