|
humayunlalzad wrote: Form2 form2;
private void button1_Click(object sender, EventArgs e)
{
if (form2 == null)
{
form2 = new Form2();
form2.Show();
}
}
this code creates a new instance if form2 is not already opened, But what to do if form2 is opened and then closed by user(by X button of form2).
i tried in else part of your block like this
else
{ form2.BringToFront();
form2.Activate();
}
but its not working. I think when user close the form2 it got disposed, but form2 instance not set to null.
How to solve this?
thanks and regards.
|
|
|
|
|
Yes you are rt. Thanx for pointing out the prob. I tried to set form2 to null in the form2 closing event, but I dont why it's not working.
but this works
private void button1_Click(object sender, EventArgs e)
{
if (form2 == null)
{
form2 = new Form2(this);
form2.Show();
}
else if (form2.IsDisposed)
{
form2 = new Form2(this);
form2.Show();
}
else
{
form2.Focus();
}
}
The only problem is that if I want to work on form2 and close form1, form2 also closes since form2.Show() had been called. Is there a way to keep form2 running even after form1 has been closed
Guys Help
|
|
|
|
|
listen, i dont know what you are trying to achieve but use the mdi forms parent/child method instead in the future.
i dont see the purpose of using many forms (or use usercontrols like pages).
nelsonpaixao@yahoo.com.br
trying to help & get help
|
|
|
|
|
Its just about understanding the mechanism. But thanx anyways.
|
|
|
|
|
listen,
if you are studying that method ok, go ahead, but like i said if you are trying to build some kind of application and you are thinking on using that method...drop it
i create applications using a single form!!! then a fill the form with lots of usercontrols that are pages.
Or you can use mdi parent/child form method.
nelsonpaixao@yahoo.com.br
trying to help & get help
|
|
|
|
|
Hi guys, I want to resize the custom control if i select the bottom left handle on the control and drag it so it can be resize. The problem is that through the bottom left handle when the custom control size reaches 20 and if further drag up the custom control doesn't change its size but it starts to move horizontally.
Can you please point me where i am doing wrong. Thanks.
private void Nodes_MouseMove(object sender, MouseEventArgs e)
{
if(NodeLocation.BottomCenter=="BottomCenter")
{
bottomCenter(n, e.X, e.Y);
}
else
{
bottomLeft(n, e.X, e.Y);
}
}
private void bottomCenter(Nodes n, int x, int y)
{
Control c = (Control)n.Tag;
n.Location = new Point(n.Location.X, n.Location.Y + y);
c.Height = c.Height + y;
}
private void bottomLeft(Nodes n, int x, int y)
{
Control c = (Control)n.Tag;
n.Location = new Point(n.Location.X + x, n.Location.Y + y);
if(c.ClientRectangle.Width > 20 && c.ClientRectangle.Height > 20)
{
c.Left = c.Left + n.Left;
c.Height = c.Height + y;
c.Width = c.Width - n.Left;
}
else
{
if( n.Left + c.Left > 20 ) ----> when button size reaches 20 and wants to ruther decrease it size then button moves horinontally {
c.Left = c.Left + n.Left;
c.Height = c.Height + y;
c.Width = c.Width -n.Left;
}
}
}
modified on Friday, November 14, 2008 12:12 PM
|
|
|
|
|
netJP12L wrote:
if(c.ClientRectangle.Width > 20 && c.ClientRectangle.Height > 20)
{
c.Left = c.Left + n.Left;
What this line refers to do?
When you're alone in the Dark, Fear will protect you...
|
|
|
|
|
Thanks for replying.
I am checking the control size if it is greater than 20 if so then setting the control left size. I even tried with
if(c.Width > 20 && c.Height > 20)
didn't really affect. I am sitting looking to solove this problem though.
|
|
|
|
|
netJP12L wrote: setting the control left size
The Left Size? As I remembered Left property gets or sets the position of a control in its container.
According to MSDN:
Control.Left: Gets or sets the distance, in pixels, between the left edge of the control and the left edge of its container's client area.
Does it make any difference?
When you're alone in the Dark, Fear will protect you...
|
|
|
|
|
Hello all,
I am planning to add Tracing instrumentation to our application. This would result in tons of adding Tracing and logging statements in almost all methods of main areas of application. Even when tracing is disabled, at minimum these statements would atleast evaluate TracingEnabled==False/True logic, which i think will have some performance impact. Any better ideas are appreciated.
Thanks.
modified on Friday, November 14, 2008 12:15 PM
|
|
|
|
|
You might want to look at Log4Net and/or an AOP framework like PostSharp. It's hard to say what the actual timing impact will be, but something like this seems more of a performance issue in actually doing the instrumentation IMHO.
Scott P
"Simplicity carried to the extreme becomes elegance."
-Jon Franklin
|
|
|
|
|
|
This doesn't help you right now, but you could beg Microsoft to include useful things like proper preprocessor macros the next time they make a programming language.
You could fudge it, sorta' like this:
void Breakpoint()
{
#if _BREAK_ENABLED
System.Diagnostics.Debugger.Break();
#endif
}
I'm pretty sure that calls to empty function bodies are effectively eliminated by the time the JIT comes into play, but I could be wrong.
--
Abort, Retry, Hurl computer into the hellfire in which it was forged?
|
|
|
|
|
Scott Bruno wrote: you could beg Microsoft to include useful things like proper preprocessor macros the next time they make a programming language
It was a deliberate decision to avoid preprocessor macros when the C# language was designed. You can do a lot with them, but they are widely used in ways that make it harder to understand the code, which is the opposite of the philosophy of the C# language.
Despite everything, the person most likely to be fooling you next is yourself.
|
|
|
|
|
Guffa wrote: It was a deliberate decision
Oh really? And all this time I thought it was accidental.
I know why they did it. I just disagree with the practice of neutering languages in an attempt to open up platform development to the less capable.
--
Abort, Retry, Hurl computer into the hellfire in which it was forged?
|
|
|
|
|
If you're using .NET 3, I'd consider using Partial methods and the Conditional attribute. A better bet though would be to use Inversion of Control to implement the tracing only when it's needed. Take a look at the Unity framework for more information/details.
|
|
|
|
|
Thanks all you guys. I will take look at unity framework, which Pete suggested.
|
|
|
|
|
HI
I have taken over a project from a former employee, I have not done OO programming for about 10 years so it is like starting over. The biggest problem I have at the moment is this. I have a grid that is populated from a dataset that I believe gets it's data from a db on my d drive. I cannot find where he defines the connection etc. I believe he did this in a using declaration but not sure. The problem is I need to take the changes from the grid and upda te the DB. When you click an update button. There is a command that already there that updates the dataset with the changes.
this.propertyTableAdapter.Update(pROTOTYP_DBDataSet.Property);
He then used this command to repopulate the grid. I do not know how to use this dataset to update the DB. I tried creating a new dataset that I was going to point at the DB but it does not show me the tables that are in the one I copied. This is the code I tried
PROTOTYP_DB.mdf
DataSet pROTOTYPDB = new DataSet();
pROTOTYPDB = pROTOTYP_DBDataSet;
If anyone could help I would really appreeciate it, I am under a tight deadline to get this woorking. The path to the DB is D:\pm_demo\PM.Runtime.Demo
Thanks
|
|
|
|
|
|
OK I'm a database programmer and have no experience with graphic programming.
My boss is wondering if I can read data into an animated display.
Similar to an o-scope. Scrolling value and time base with the data line graph in real time.
Where can I find some info on how to get something like this started??
TIA
Rafone
Statistics are like bikini's...
What they reveal is astonishing ...
But what they hide is vital ...
|
|
|
|
|
The most efficient way should be using a third party control. For example Steema[^] has a graph type FastLine in TeeChart component library.
Another possibility could be Dundas[^].
The need to optimize rises from a bad design.
My articles[ ^]
|
|
|
|
|
Well, it appears as if normal (non administrator) users using Vista don't have sufficient permissions to allow applications to create/write event log. Is this true? If so, that's insanely stupid.
Is there a work-around that doesn't involve running the application as administrator?
"Why don't you tie a kerosene-soaked rag around your ankles so the ants won't climb up and eat your candy ass..." - Dale Earnhardt, 1997 ----- "...the staggering layers of obscenity in your statement make it a work of art on so many levels." - Jason Jystad, 10/26/2001
|
|
|
|
|
You should be able to write to an event log, its creating an EventSource that you cant do using a normal account.
This was the case pre-vista as well. generally you create the event source using an installer that must be run as adminsitartor to succeed.
|
|
|
|
|
Exactly what J4amieC said. Just to add, that typically I create necessary event sources during the setup process since the setup is often (in my cases) ran using an administrator account.
The need to optimize rises from a bad design.
My articles[ ^]
|
|
|
|
|
Dear all I'm looking for some advice.
An access 2003 app exist on a corporate network but does not have the functionality required. IT won't support a connection to their SQL server and the app needs to be redevloped to included additional functionailty.
There are a number of locations where staff logon to a shared drive and need to update information in the database. There's around 10 users.
My question is should I redevelop the app to be a desktop application (c#) with an access backend or use something else.
Thank you for any information you can offer.
|
|
|
|