|
It's trying to tell you that something is null; this.MdiParent or MdiParent.MdiChildren is null. Check for that condition before entering the loop.
---------------------------
He who knows that enough is enough will always
have enough.
-Lao Tsu
|
|
|
|
|
Hi,
Im sorry Judah, im a beginner...i would appreciate it if you could show me how i can do that.
thx in advance
CODER
|
|
|
|
|
bool FrmIsOpen = false;
if(this.MdiParent != null && this.MdiParent.MdiChildren != null)
{
for (int i=0; i < this.MdiParent.MdiChildren.Length; i++)
{
if (this.MdiParent.MdiChildren[i].GetType() == typeof(FrmPassword))
{
FrmIsOpen = true;
break;
}
}
}
if (!FrmIsOpen)
{
FrmPassword r = new FrmPassword();
r.MdiParent = this;
r.Show();
}
---------------------------
He who knows that enough is enough will always
have enough.
-Lao Tsu
|
|
|
|
|
My first question would be where is this code sitting?
Is it in a child form or an MDIParent? It looks like a parent form has this code, in which case the parent form has no MDIParent. This reference would be null, and therefor, your reference to 'this.MdiParent.MdiChildren.Length' would return null. If this code is in a parent form, then your reference should be this.MdiChildren.Length.
RageInTheMachine9532
|
|
|
|
|
its in a parent form. i tried editing the code your way..but it is still able to open up two same forms...
<br />
bool FrmIsOpen = false; <br />
<br />
if(this.MdiParent != null && this.MdiChildren != null)<br />
{<br />
for (int i=0; i < this.MdiChildren.Length; i++) <br />
{ <br />
if (this.MdiParent.MdiChildren[i].GetType() == typeof(FrmPassword)) <br />
{ <br />
FrmIsOpen = true; <br />
break; <br />
} <br />
}<br />
}<br />
if (!FrmIsOpen) <br />
{ <br />
FrmPassword r = new FrmPassword(); <br />
r.MdiParent = this;<br />
r.Show(); <br />
} <br />
CODER
|
|
|
|
|
OK. The loop now runs but your references in your if statement are still screwed up. Use this instead:
bool FrmIsOpen = false;
if (this.MdiChildren.Length > 0)
for (int i=0; i < this.MdiChildren.Length; i++)
{
if (this.MdiChildren[i].GetType() == GetType(FrmPassword))
{
FrmIsOpen = true;
break;
}
}
}
if (!FrmIsOpen)
{
FrmPassword r = new FrmPassword();
r.MdiParent = this;
r.Show();
}
The first bolded statement was changed because 'this.MDIParent' will always return null if 'this' is an MDIParent. This was changed to checking if the MDIChildren collection has anything in it. In the second bolded statement, the 'typeof()' reference was changed to 'GetType()'. If you have to, you could change this to 'Type.GetType()'. This should take care of your problem.
RageInTheMachine9532
|
|
|
|
|
hey guys,
well this is my problem. I am trying to read a text file ,with information such as these three lines, insert it into the program, then seperate them into a usable format for use. There are about 1000 such lines, but speed is not neccessarily an issue. Thanks for the help.
501,Red_Potion,Red Potion,0,50,,70,,,,,10477567,2,,,,,
502,Orange_Potion,Orange Potion,0,200,,100,,,,,10477567,2,,,,,
503,Yellow_Potion,Yellow Potion,0,550,,130,,,,,10477567,2,,,,,
i was kinda wondering if there was same way to use a multidimentional array where the rows are the text files lines and the columns are the different values.
|
|
|
|
|
how about:
ArrayList table = new ArrayList;
SreamReader txtFile = new StreamReader("myfile.txt");
while ((string reader = txtFile.ReadLine()) != null) {
table.add(reader.Split(","));
}
txtFile.Close();
Matthew Hazlett
Windows 2000/2003 MCSE
Never got an MCSD, go figure...
|
|
|
|
|
Hi!
does anyone have some experience with Jpeg2000 and .NET ???
can someone give me some code samples how to compress a picture to
Jpeg2000 with .NET ???
and how to show a Jpeg2000 picture although the picture is not loaded
complete??? (show the Jpeg2000 picture with a lower quality).
how to send (upload) DICOM Header of a Jpeg2000 picture???
best regards,
gicio
|
|
|
|
|
Hi!
does anyone have some experience with BITS
(Background Intelligent Transfer Service) and .NET ???
can someone give me some code samples how to use BITS with .NET ???
regards,
gicio
|
|
|
|
|
Check MSDN, there are several example articles there.
- Nick Parker My Blog
|
|
|
|
|
|
Hi!!
does anyone some experience with BITS
(Background Intelligent Transfer Service) and SSL and .NET ????
can someone give me some code samples how to use it?
regards,
gicio
|
|
|
|
|
I have several devices on a local network that I talk to. But if a device is turned off, .Connect takes more than 30 seconds to return. How do I get .Connect to timeout, within a second, if the device is not on the network?
Brian
|
|
|
|
|
Socket.SetSocketOption() method
Mazy
"A bank is a place that will lend you money if you can prove that you don't need it." - Bob Hope
|
|
|
|
|
I set the SocketOptionName.SendTimeout and SocketOptionName.ReceiveTimeout, but it didn't affect the Connnect timeout.
Brian
|
|
|
|
|
Hi, all!
How can I crate TextBox which would display 'circles' instead of '*' in WinXP?
Currently I have TextBox with PasswordChar set to '*' because of I do not know how else I can say that this is a PasswordBox.
I enabled Visual Styles through manifest but it still shows '*'
Thanks.
Regards,
alexx.
|
|
|
|
|
you can use the dot character (copy and paste one of these)
• ( U+0222 arial)
● ( U+25CF times new roman)
or any other character in the Windows' CharactersMap (unicode section)
|
|
|
|
|
Hello, Claudio!
But in that case I'll got the same char in Win2k and I do not want to.
Thanks.
Regards,
alexx
|
|
|
|
|
if you want to display the normal asterisk character in a Windows System < win2K
you can use this:
<br />
if ((Environment.OSVersion.Version.Major >= 5) || ( (Environment.OSVersion.Platform == PlatformID.Win32NT) && (Environment.OSVersion.Version.Major == 4) ))<br />
{<br />
textBox1.PasswordChar= '•';
}<br />
bye
|
|
|
|
|
Look for TextBox.PasswordChar property. You have to set this property.
Mazy
"A bank is a place that will lend you money if you can prove that you don't need it." - Bob Hope
|
|
|
|
|
|
A simpler way is to set the PasswordChar property. This re-creates the handle of the TextBox with the ES_PASSWORD style.
Microsoft MVP, Visual C#
My Articles
|
|
|
|
|
Hi, all!
I have several controls, bounded to public properties of my Settings class. Those are edit boxes, check boxes and combo. MSDN says that in this case bounded property is updated immedeatly when control's text changes, but I have update is done only after control looases focus...
What is wrong? I want to track changes to Enable Apply button on my form after user changes one of the controls text.
Thanks.
Regards,
alexx.
|
|
|
|
|
The control's text isn't changed until the control looses focus. Up until then, you're merely filling the UI with data. The text isn't committed to the appropriate property until it looses focus. To see this, handle the TextChanged event, for example. Things like check boxes are set immediatley, though, because it requires a simple action (a click).
If you want to get an order of events that happen, see the GotFocus Event[^] documentation in the .NET Framework SDK, for example.
You'll also notice this behavior in Windows in some places, too. If you want to change it, you could assume that any change to a TextBox (for example) will change the data (even though they might undo their changes). There's many ways you could handle this solution. For instance, handle the KeyUp event (handling this as opposed to KeyDown at least lets savvy users press Esc before letting up to cancel the current character) and enabling your Apply button in the handler. You could, in this case, simply point all TextBox es to the same handler as well.
Microsoft MVP, Visual C#
My Articles
|
|
|
|
|