|
I want to create a child form within a mdi that behaves somewhat like a dialog form and I know that I can't do that and that it would defeat the purpose of an mdi all together but here is my dilemma. I need for the child form after a button is clicked on that child form for it to return to the parent form so I can pull values from it. Now if it was a dialogue I could do something like this;
if(form.ShowDialog == DialogResult.OK)
{
any information I want to pull from my dialog I can put here.
}
How can I accomplish this in this case?
|
|
|
|
|
It's a bit of a hack, but you could make an event in the child an fire it when it's about to close. You could even pass the info in the event parameters.. (or just pull them from the child form directly)
|
|
|
|
|
harold aptroot wrote: bit of a hack, but you could make an event in the child
Not a hack, this is exactly what events are for
DaveBTW, in software, hope and pray is not a viable strategy. (Luc Pattyn)Visual Basic is not used by normal people so we're not covering it here. (Uncyclopedia)
|
|
|
|
|
That is a good solution and I prefer it. But if you are not familiar with events, a naive solution can also be for the child to call some properties of the parent form and provide the information before it is closed. For example:
class Parent
{
public void foo()
{
MyChildForm child = new MyChildForm();
child.Show();
}
public string SetThisMyChild
{
set
{
_comingFromChild = value;
}
}
private string _comingFromChild;
}
public class MyChildForm
{
public void CloseButton_Click(object sender, EventArgs e)
{
_mainForm.SetThisMyChild = something;
}
}
|
|
|
|
|
Hello everyone,
I met with timeout issue. Here is my whole code. I just send Http request to two local LAN servers and see if response could be received in given time, then I treat the server as healthy, or else I will treat them as unhealthy.
The two servers are simple ASP.Net ASMX Web Serviers Web Servers on IIS. The timeout will happen for both servers are PingServers method executing for 4-5 times successfully. It is strange timeout since the server are pretty fast -- I use IE to access the same URL, it takes less than 1 second to return, but in my code, I set timeout to be 4 seconds, it will prints timeout.
Does anyone have any ideas? Any bugs in my code?
static void PingServers(Object state)
{
HttpWebRequest request = (HttpWebRequest)WebRequest.Create((String)state);
request.Timeout = 4 * 1000;
HttpWebResponse response = null;
try
{
response = (HttpWebResponse)request.GetResponse();
}
catch (WebException ex)
{
Console.WriteLine((String)state + " " + ex.ToString());
return;
}
Console.WriteLine((String)state + " is healthy");
return;
}
static Timer[] monitorTimers = new Timer[2];
static void Main(string[] args)
{
monitorTimers[0] = new Timer(PingServers, "http://localserver1/test/test.ashx", 0, 10 * 1000);
monitorTimers[1] = new Timer(PingServers, "http://localserver2/test/test.ashx", 0, 10 * 1000);
Console.ReadLine();
return;
}
thanks in advance,
George
|
|
|
|
|
How to translate the property of the control in the properties window?
For example,there is a Button on the winForm,then many properties is listed in the properties windows,such as Text、BackColor,now I want to translate the name of the property from english into other languange:
for instance:
English Chinese
Text 文本
BackColor 背面颜色
Thanks all in advance!
|
|
|
|
|
Donwload the .NET languagepack[^] of your choice and install it. It doesn't only translate error-messages, but also properties, if I'm not mistaken.
You cannot translate the texts by yourself, since there is no interface.
|
|
|
|
|
Thank Eddy for your answer.
I remember my colleague I have achieved this funtion in his program,not handling by the system languagepack,He can change the Text property of the button with any name.
|
|
|
|
|
The language-pack does it automatically, and the translations are embedded deep in the .NET runtime. It's a low-impact solution to your question, and I suggest you take a look at it before experimenting with sourcecode.
BTW, my Visual Studio IDE @ work uses these Dutch language-packs, and it's bloody annoying to search for something simple like "ForeColor". Not only is the sort-order different (Voorgrondkleur), but it's in a category with a different name. It gets worse when you're facing a localized version of an error - and you need to search the English-based MSDN for the same error.. It doesn't increase the productivity, it just causes more bugs.
Within the computer, everything should remain in a single language. That has nothing to do with the language that the end-user sees. It's just not possible to teach a computer all the localized versions of a boolean.
mctramp168 wrote: I remember my colleague I have achieved this funtion in his program,not handling by the system languagepack,He can change the Text property of the button with any name.
Phone your collegue, ask how he did it
You could also redefine the property-names, as shown in the example below;
[Browsable(false)]
public override System.Drawing.Color ForeColor
{
get
{
return base.ForeColor;
}
set
{
base.ForeColor = value;
}
}
[Browsable(true), Category("Appearance")]
public System.Drawing.Color VeurgrondKleur
{
get
{
return this.ForeColor;
}
set
{
this.ForeColor = value;
}
}
This will hide the "ForeColor" from the property-editor in Visual Studio. This example was built on a derivate of a textbox.
I wouldn't dub that a good programming practice. It makes things more complex, without actually adding much value. If you're facing a development-team that has a hard-time with English, then consider upgrading their knowledge of the language. The ROI would be higher when you train the Visual-Studio-user to communicate in English then trying to adapt the environment to the user.
Hope this helps,
I are troll
|
|
|
|
|
Thank Eddy for your zealous help.
I know your above handleing method,if each property is handled like that, It needs a lot of time, I saw a set software, it can let non-programmer user to design a winform after you teach them simply, the winform's property is translated by the programmer, then the non-programmer can very easy to learn to design simple winform. I only want to know this skill of translating the property of the control.
I try to ask my past colleague.
Thanks !
|
|
|
|
|
i need to detect windowstate outside form
ex. my application is running when i open a application (ex. internet explorer), i need to detect windowstate of internet explorer
how can i do it?
please give some tip or hint to me
thanks a lot...^^
|
|
|
|
|
Hi,
this is a two-step process requiring some P/Invoke to Win32 functions:
1. find the handle of the right window; depending on what you know about it, you can read
Process.MainWindowHandle; or by enumerating all windows, see EnumWindows[^]
2. now get information on that window, possibly by calling GetWindowPlacement[^]
Luc Pattyn [Forum Guidelines] [My Articles]
I use ListBoxes for line-oriented text output (not TextBoxes), and PictureBoxes for pictures (not drawings).
modified on Friday, June 10, 2011 12:14 PM
|
|
|
|
|
GetWindowPlacment <- how to use it?
i'm testing, but i don't understand about this function.
if i need to know application state, ex. minimize, maximize, normal
how can i do? i'll get information window to compare.
please give more tip or hint to me.
thanks so much...
|
|
|
|
|
Hi,
I gave you the link to the MSDN page on GetWindowPlacement; what you want is the value of showCmd.
Since this is a native function and your app is a .NET app, you will need some P/Invoke stuff; I hope you are familiar with that, if not be warned, it ain't that simple.
Here is a link to P/Invoke GetWindowPlacement[^].
Luc Pattyn [Forum Guidelines] [My Articles]
I use ListBoxes for line-oriented text output (not TextBoxes), and PictureBoxes for pictures (not drawings).
modified on Friday, June 10, 2011 12:14 PM
|
|
|
|
|
|
Hello everyone,
I met with a system hang issue (a program does not run to complete). It is a managed code program (C# console) and run on Windows Server 2003 x64. Are there any ideas or recommended documents about how to narrow down such hang problem?
thanks in advance,
George
|
|
|
|
|
What that application is doing? Is that entering into some infinite loop?
|
|
|
|
|
Thanks Navaneeth,
The application is dealing with sending data to a web services and retrieve results to analyze. Any general ideas to debug and analyze further for application hang problem?
regards,
George
|
|
|
|
|
George_George wrote: Any general ideas to debug and analyze further for application hang problem?
You can step into the code and check which line execution is hanging. Identify why it is hanging. If the method which is hanging provides a timeout mechanism, use that so that your code will timeout if it can't process within the limit and will not make the whole application hang.
|
|
|
|
|
|
Hi George,
1.
if only one app hangs, you shouldn't call it a system hang. You are not going to reboot are you?
2.
if the problem occurs consistently you might just perform normal debugging. if on the other hand the
hang is occasional, I would add tracing code, so the app reports its activities to a file, one line at a time, with the time prefixed. In fact I always do that, from the very beginning, long before it starts to go wrong; and I tend to use File.AppendText so the file is normally closed and can be read while the app is running.
Without trace logs, intermittent or occasional problems are hard to debug, while single-stepping and breakpointing, you are never sure the problem will occur...
With trace logs, you can focus on a bad run; or you can compare traces from a bad run with those from a good run.
|
|
|
|
|
Luc Pattyn wrote: Without trace logs, intermittent or occasional problems are hard to debug, while single-stepping and breakpointing, you are never sure the problem will occur...
With trace logs, you can focus on a bad run; or you can compare traces from a bad run with those from a good run.
That's a good suggestion
|
|
|
|
|
Agree, Navaneeth.
regards,
George
|
|
|
|
|
|
I have lots of ideas, the first and most important ones are here already[^].
Luc Pattyn [Forum Guidelines] [My Articles]
I use ListBoxes for line-oriented text output (not TextBoxes), and PictureBoxes for pictures (not drawings).
modified on Friday, June 10, 2011 12:14 PM
|
|
|
|