|
Dennis C. Dietrich:
I have found the MDIParent property in the Form class as you had suggested, but I am uncertain how to implement it. Puzzling thing is though, why isn't the MDIParent property available in the Properties window, is it an abstract class or something? Do I implement it in the child class like this in the onLoad event like so:
frmMainForm frm = new frmMainForm();
this.MDIParent = frm;
and should I select isMDIParent in the Main Form first? Trouble is, when I do select isMDIParent to true, the background color shifts (for some reason) to a light gray, even when I change the background color back to the preferred designated color. An alternative optional guess of how to implement the MDIParent property would be to put:
frmChildForm frmChild = new frmChildForm();
this.MDIChild = frmChild;
into either the form designer section with all of the variable assignments, or into the onLoad button for the frmMainForm form. What IS the PROPER way to implement an MDI form in C#?
Also, with regard to the implementation of the KeyDown event, could I implement a KeyDown event at the form level? How would I implement a KeyDown event trap for the UP and DOWN arrows for example? Using your code as an example, could you kindly assist me in correcting this revised code, and please explain to me why the code is not being triggered by pressing the TAB button:
<br />
this.KeyDown += new System.Windows.Forms.KeyEventHandler(this.frmSolitaireMainForm_KeyDown);<br />
<br />
private void frmSolitaireMainForm_KeyDown(object sender, System.Windows.Forms.KeyEventArgs e)<br />
{ <br />
if (e.KeyCode == Keys.Tab)<br />
{<br />
if (statusBar.Visible == true)<br />
{<br />
statusBar.Hide();<br />
e.Handled=true;<br />
}<br />
else<br />
{<br />
statusBar.Show();<br />
e.Handled=true;<br />
}<br />
}<br />
}<br />
|
|
|
|
|
new_phoenix wrote:
I have found the MDIParent property in the Form class as you had suggested, but I am uncertain how to implement it.
I didn't suggest that. That was Senthil.
new_phoenix wrote:
Puzzling thing is though, why isn't the MDIParent property available in the Properties window, is it an abstract class or something?
This makes perfectly sense. The Form.MdiParent Property[^] is of the type Form[^]. Accordingly you need to assign an instance of that class and that of course is only possible at runtime.
new_phoenix wrote:
Do I implement it in the child class like this in the onload event like so:
I'm wondering if you actually read the information on MSDN I mentioned. It's all explained there including working code samples. So, again please check out Multiple-Document Interface (MDI) Applications[^] (especially Creating MDI Child Forms[^]).
new_phoenix wrote:
and should I select isMDIParent in the Main Form first?
If you don't set the Form.IsMdiContainer Property[^] to true you'll get an exception when trying to show a MDI Child.
new_phoenix wrote:
Also, with regard to the implementation of the KeyDown event, how would I implement a KeyDown event trap for the UP and DOWN arrows for example?
There isn't anything like an "event trap". I suggest you read some paragraphs about event handling and delegates (see Events Tutorial[^] and Delegates Tutorial[^]). The code I posted in my previous message is an example for an event handler for the Control.KeyDown Event[^]. As the type of the KeyEventArgs.KeyCode Property[^] is Keys[^] and Keys is an enumeration[^] you don't have to define the key codes yourself.
Best regards
Dennis
|
|
|
|
|
Dennis:
Thanks! The resources you had provided will be very helpful. I was just reading through it and it will take some time to digest. This is a new concept to me and I have not implemented it before - not covered in school very well. I appreciate the direction toward more information about the implementation of events and delegates as the textbooks that I have read do not cover it very well.
Thanks again!
New_Phoenix
|
|
|
|
|
Did you try setting the form's KeyPreview property to true?
Regards
Senthil
My Blog
|
|
|
|
|
How can i get to the registry files and add keys and stuff using C#?
|
|
|
|
|
|
Hello,
How do I make an add-in that when someone right clicks on any selected text, that in a context menu that appears an option appears that I have made(don't know how to do) does executes a bit of code..
Thanks in advance..
modified 19-Aug-21 21:01pm.
|
|
|
|
|
hi,
I know how to format a paragraph programmatically, using "\r" to return to the next line in a rich text box, and continue adding text to the next line. but there are a couple problems I've run into doing this. first, I hate putting a giant paragraph on a single line, cause it makes the (i think it's called) buffer really wide, kinda like not turning on word wrap. Secondly, my main problem is, it takes a long time to insert all the + "\r" + "text "\r", etc. is there an easier way to do this? if not, someone should make a tutorial with an app. I thought about trying to do this myself, but I don't know how to use regular expressions very well, which seems the best way to go about making an app that could do this. that could automatically reveal formatting. Keep in mind, I would like to insert this text at the current cursor position. thanks for the help,
Stephen
|
|
|
|
|
A "buffer" is a block of memory that holds data. The text buffer (a char[] array, actually) will be even larger if you insert return codes because you'll be including 1-2 extract characters every so often. How the buffer is displayed is a user interface.
If you want to insert a return code you must use the correct return code for the underlying platform. The Environment.NewLine property abstracts this detail away from you, since - on Windows - the actual new line constant is "\r\n". For console output you can use simply "\n" which gets translated appropriately, but for most text you should use Environment.NewLine . For example:
string value = string.Format("This is a{0}broken line.{0}This is a separate line.", Environment.NewLine);
label1.Text = value;
This posting is provided "AS IS" with no warranties, and confers no rights.
Software Design Engineer
Developer Division Sustained Engineering
Microsoft
[My Articles] [My Blog]
|
|
|
|
|
thanks for the help. I was wandering though,is there a way to actually reveal formatting. like, insert text into one richTextBox and then ouput the text with the formatting symbols ("\r\n"), or the thing you showed me in a second richTextBox? This would be very very helpful to me. thanks again.
|
|
|
|
|
ok I think I figured it out. one thing though, how do I insert the text "\r\n" as text, without using it as actual formatting.
|
|
|
|
|
You can escape them like "\\r\\n" or use the verbatim modifier @"\r\n".
Regards
Senthil
My Blog
|
|
|
|
|
I am writing a prog that will process data every 15 mins to 1 hour.
I have looked at System.Timer and Window Timer but they seem to be conern about millisecond timing and I presume that the amount of resources (processer and RAM) that it requires might be wasted since I only require accuracy of a minute.
I was wondering if you guys actually use Timers with elapse time of 15 mins - an hour or is there a better solution for this.
|
|
|
|
|
A timer uses very little resources because it works with your system clock which is essential to making your computer work. Your CPU and system clock work together. Any computer engineering book you could pick up will help you understand this better.
Note that there are actually 3 timers in the .NET BCLSystem.Threading.Timers System.Timers.Timer - System.Windows.Forms.Timer
Each have a resolution of 1 millisecond but work different ways, like requiring a callback or exposing an event (to which you add a handler, or callback).
This posting is provided "AS IS" with no warranties, and confers no rights.
Software Design Engineer
Developer Division Sustained Engineering
Microsoft
[My Articles] [My Blog]
|
|
|
|
|
Hi,
I have a tabcontrol with 4 tabpages.
Each tabpage contains a richtextbox.
I do not have anyproblem running my application and viewing all the tabs when the system font is set to small font. When the font is set to large font, all the tab pages become gray and the richtextboxes are not shown at all!
Does anyone know of a solution to this problem?
(setting the AutoSize property of the RichTextBoxes to true does not help )
Thanks.
avivhal
|
|
|
|
|
How exactly do you mean? The system fonts are set to large while your application is running and the TabControl shown, or even when the fonts are set to large before your application is running? The latter should not cause problems, but the former situation can. Handling the SystemEvents.UserPreferenceChanged event may help so that you can react accordingly, often times call Control.Update on controls that having trouble updating their drawing surface themselves.
This posting is provided "AS IS" with no warranties, and confers no rights.
Software Design Engineer
Developer Division Sustained Engineering
Microsoft
[My Articles] [My Blog]
|
|
|
|
|
The system font is set to large before the application is running. This causes the tabs not to appear. If the font is set to small the problem is gone and all tabs are shown.
I have actually only seen this behavior on windows 2000 systems. On XP the problem does not exist. Does this make any difference?
Could it be a .NET CLR issue?
Thanks.
avivhal
|
|
|
|
|
No, it would not be a CLR issue. For one, the CLR is the same - for the most part - for all supported platforms. There are small differences, like that the CLR on 9x will thunk Unicode text, but understand that most of the Windows Forms controls are just encapsulating the Windows Common Controls. They are not - except for a few like DataGrid and many of the upcoming new controls in .NET 2.0 - implemented "natively" (i.e., not as pure .NET classes). This is to provide a consistent UI with the rest of Windows.
It could be a problem with the underlying Tab-Control common control. Reproduce the steps using a native application that uses the Tab-Control and see if you see the same problem. Also make sure your system is up-to-date by visiting Windows Update.
This posting is provided "AS IS" with no warranties, and confers no rights.
Software Design Engineer
Developer Division Sustained Engineering
Microsoft
[My Articles] [My Blog]
|
|
|
|
|
I got a programs like below, and I dunno how to make it user input. The data that I need user to input are :ratio, maxqsize,pgr,packetSize, and bandwidth.
I'm trying with the
ratio=double.Parse(tbSRuns.Text);
maxqsize=in.Parse(tbmaxqsize.Test);...........
and try to implement witn error exception but it seems not work.
pls help me very urgent (
the code is here: just can download
http://s22.yousendit.com/d.aspx?id=086RE5J2BGVV40YK3Z3VQ4QZ7Y
|
|
|
|
|
Hi tyenchoo,
What error are you getting? Dobule.Parse, Int32.Parse() methods convert string to corresponding type. Can you lets us know the error.
Regards
SGS
|
|
|
|
|
i have use this method to pass date, but i found that i cannot pass the value between class, izzit use pass by data or pass by reference? can giv example?
|
|
|
|
|
I am just working with PictureBox and I have to draw rectangle over picture. I take Graphics object and use DrawRectangle. Then, I have to move or resize this rectangle, so first I need to restore previous image. I do it with
Graphics.DrawImage(SourceImage, Rect, Rect, …), but I think it not the fastest way.
...
grPicBox.DrawImage(PicBox.Image, LastRect, LastRect, GraphicsUnit.Pixel);
grPicBox.DrawRectangle(RedPen, CropRectangle);
…
I’m searching for better idea.
Thanks!
-------------
Lukasz Szymik
|
|
|
|
|
From where is this code called? You might consider not even redrawing the image synchronously, but enabling double buffering and calling Control.Update when moving the rectangle. This will cause the control to redraw the image in a background thread and flip the buffer to the control's surface when resources are available. See the documentation[^] for the ControlStyles enumeration, which you pass to Control.SetStyle .
Also note that you should do as much drawing as possible in an override to OnPaint (do not handle events when extending controls, which is a more robust solution than handling events on an external class), being sure to call base.OnPaint when appropriate. In that case, use PaintEventArgs.Graphics that is passed to you and do not dispose it yourself, like you normally would if you use Control.CreateGraphics . The latter call can be expensive, too, so depending on how your code above is used - which is why I asked - could also be the source of poor performance if you're creating a new Graphics for each call to OnMouseMove .
This posting is provided "AS IS" with no warranties, and confers no rights.
Software Design Engineer
Developer Division Sustained Engineering
Microsoft
[My Articles] [My Blog]
|
|
|
|
|
Thank You very much, double buffering is perfect for my application
-------------
Lukasz Szymik
|
|
|
|
|
Hi folks!
In another forum someone was asking how to serialize a class like this using XmlSerializer:
class Test
{
public Test() {}
private int someval;
public int SomeVal
{
get { return someval; }
set { someval = value; }
}
private object tag;
public object Tag
{
get { return tag; }
set { tag = value; }
}
}
Whether XmlSerializer is able to serialize an instance of this class or not is depending on the value of Tag , strangely enough.
When Tag is an int or string for example, everything works fine.
When Tag is an int[] , for example, you get an exception during serialization.
That's the first thing I can't understand. Having an int[] property in the class serializes just fine.
At first I thought the XmlSerializer is having problems when it doesn't know the type to serialize beforehand, but then I changed the definition of the class a bit and suddenly it worked:
Only by adding this property:
private int[] dummy;
public int[] Dummy
{
get { return dummy; }
set { dummy = value; }
} I could get the XmlSerializer to not throw an exception when serializing the class with an int[] assigned to the Tag property!
Can anyone imagine what's going on there?
Thanks in advance,
mav
|
|
|
|