Click here to Skip to main content
15,908,111 members
Home / Discussions / C#
   

C#

 
AnswerRe: Reading VB6 PropertyBag using C#? Pin
LongRange.Shooter23-Oct-06 4:30
LongRange.Shooter23-Oct-06 4:30 
QuestionMouse button click... Pin
new_phoenix21-Oct-06 11:19
new_phoenix21-Oct-06 11:19 
QuestionWhat's the meaning of the following code? Pin
Ming Luo21-Oct-06 10:46
Ming Luo21-Oct-06 10:46 
AnswerRe: What's the meaning of the following code? Pin
Tamimi - Code21-Oct-06 19:59
Tamimi - Code21-Oct-06 19:59 
QuestionHow to detect Attempt to connect? Pin
FlyOnIT21-Oct-06 9:52
FlyOnIT21-Oct-06 9:52 
AnswerRe: How to detect Attempt to connect? Pin
LongRange.Shooter23-Oct-06 4:32
LongRange.Shooter23-Oct-06 4:32 
QuestionNeed To license source or component. Pin
hdv21221-Oct-06 8:44
hdv21221-Oct-06 8:44 
QuestionHow to identify whether or not a control object has been instantiated... [modified] Pin
new_phoenix21-Oct-06 7:46
new_phoenix21-Oct-06 7:46 
I have a suspicion that one of the controls in my control array has not been properly instantiated. Because at least one of the controls in the control array was not instantiated properly when the form was loaded, then when those improperly instantiated controls in the control array are attempted to be randomized, they cannot be done properly because they were not instantiated properly in the first place. When I run the program without randomizing the control array, the application works fine.

Stephan was kind enough to provide some input as to how to randomize a control array. I should note that the randomization function itself works fine. The problem is somewhere possibly with the index in the control array. It is only when each of the elements from the randomized control array are parented to each other that I get the following error:

However, when I enable the randomization function, I get the following error:

"An unhandled exception of type 'System.NullReferenceException' occurred."

"Additional information: Object reference not set to an instance of an object."

I would really appreciate some insights as to how I could prove that each of the controls in the control array both before and after randomization has been properly instantiated. Trouble is, when I step through each of the steps, it appears to be a different control each time that it is not finding a reference assignment for the instance. I understand that there is a way to Trace() variables into a log file. Could somebody please provide a primer as how this is accomplished?

The slightly modified code for the randomization process is as follows. I would appreciate some additional input.

<br />
public CardControl[] cardName = new CardControl[53];<br />
...<br />
private void ShuffleCards(card[] cards)<br />
{<br />
    ArrayList list = new ArrayList(this.cardName);<br />
    Random rand = new System.Random();<br />
    int j = 0;<br />
    for (int k = 0; k < this.cardName.Length; k++)<br />
    {<br />
        j = rand.Next(list.Count);<br />
        this.cardName[k] = (CardControl)list[j];<br />
        string strCardName = this.cardName[k].Name;<br />
        list.RemoveAt(j);<br />
    }<br />
}<br />


Is there some kind of "Object Window" that I could use to see what objects have been instantiated correctly while stepping through the code. I would also need to know the properties of each object and their names.
Confused | :confused: Confused | :confused: Confused | :confused:



-- modified at 14:53 Saturday 21st October, 2006
AnswerRe: How to identify whether or not a control object has been instantiated... Pin
Guffa21-Oct-06 8:59
Guffa21-Oct-06 8:59 
GeneralRe: How to identify whether or not a control object has been instantiated... [modified] Pin
new_phoenix21-Oct-06 9:28
new_phoenix21-Oct-06 9:28 
GeneralRe: How to identify whether or not a control object has been instantiated... Pin
Guffa21-Oct-06 11:56
Guffa21-Oct-06 11:56 
QuestionForm Updating within Loops Pin
Jethro6321-Oct-06 6:06
Jethro6321-Oct-06 6:06 
AnswerRe: Form Updating within Loops Pin
User 665821-Oct-06 6:41
User 665821-Oct-06 6:41 
GeneralRe: Form Updating within Loops Pin
Jethro6321-Oct-06 19:19
Jethro6321-Oct-06 19:19 
QuestionHow to make an number only text box? Pin
Ming Luo21-Oct-06 5:50
Ming Luo21-Oct-06 5:50 
AnswerRe: How to make an number only text box? Pin
User 665821-Oct-06 6:44
User 665821-Oct-06 6:44 
AnswerRe: How to make an number only text box? Pin
3Dizard21-Oct-06 10:12
3Dizard21-Oct-06 10:12 
GeneralRe: How to make an number only text box? Pin
Martin2323-Oct-06 0:18
Martin2323-Oct-06 0:18 
Questionhow to Genarate report ??? Pin
iyoko21-Oct-06 5:38
iyoko21-Oct-06 5:38 
Questionhow retrieve data from Cookie?? Pin
iyoko21-Oct-06 5:36
iyoko21-Oct-06 5:36 
AnswerRe: how retrieve data from Cookie?? Pin
Guffa21-Oct-06 6:51
Guffa21-Oct-06 6:51 
GeneralRe: how retrieve data from Cookie?? Pin
iyoko21-Oct-06 22:43
iyoko21-Oct-06 22:43 
QuestionNetwork System.Net.Dns.GetHostByAddress is too slow Pin
bradsnobar20-Oct-06 21:55
bradsnobar20-Oct-06 21:55 
AnswerRe: Network System.Net.Dns.GetHostByAddress is too slow Pin
User 665820-Oct-06 23:43
User 665820-Oct-06 23:43 
QuestionHow to safely raname a vs 2005 project Pin
_marsim_20-Oct-06 21:17
_marsim_20-Oct-06 21:17 

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.