|
Best way to solve this is to to make your class constructor private and put static method that returns reference to only instance of your class
Code example:
<br />
class Example<br />
{<br />
private static Example THIS = null;<br />
<br />
public static Example CREATE_FORM()<br />
{<br />
if (THIS == null)<br />
THIS = new Example();<br />
<br />
return THIS;<br />
}<br />
<br />
private Example()<br />
{<br />
}<br />
}<br />
|
|
|
|
|
if( myForm != null && !myForm.Disposing && myForm.IsHandleCreated)
return;
else
myForm.Show();
|
|
|
|
|
hi i am currently using c# visual studio 2005 window application
and i would like to make an event handler which would execute when a string variable data changes
i though it may be possible when i came accross form1.desinger.cs and saw the codes like:
private void InitializeComponent()<br />
{<br />
this.textBox1 = new System.Windows.Forms.TextBox();<br />
this.button1 = new System.Windows.Forms.Button();<br />
this.SuspendLayout();<br />
this.textBox1.Location = new System.Drawing.Point(89, 127);<br />
this.textBox1.Name = "textBox1";<br />
this.textBox1.Size = new System.Drawing.Size(100, 20);<br />
this.textBox1.TabIndex = 0;<br />
this.textBox1.TextChanged += new System.EventHandler(this.textBox1_TextChanged);<br />
this.button1.Location = new System.Drawing.Point(203, 198);<br />
this.button1.Name = "button1";<br />
this.button1.Size = new System.Drawing.Size(75, 23);<br />
this.button1.TabIndex = 1;<br />
this.button1.Text = "button1";<br />
this.button1.UseVisualStyleBackColor = true;<br />
this.button1.Click += new System.EventHandler(this.button1_Click);<br />
this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);<br />
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;<br />
this.ClientSize = new System.Drawing.Size(292, 266);<br />
this.Controls.Add(this.button1);<br />
this.Controls.Add(this.textBox1);<br />
this.Name = "Form1";<br />
this.Text = "auction";<br />
this.Load += new System.EventHandler(this.Form1_Load);<br />
this.ResumeLayout(false);<br />
this.PerformLayout();
|
|
|
|
|
One way to achieve what you are looking for would be to create a Property for the string variable and raise the event yourself in the setter..
|
|
|
|
|
how can i do that?
what are the steps involve?
|
|
|
|
|
you should be able to figure that out. but this should get you started (warning this is uncompiled, untested:
public delegate void MyStringChangedDelegate(string newVal);<br />
public event MyStringChangedDelegate MyStringChanged;<br />
<br />
<br />
string myString; <br />
public String MyString<br />
{<br />
get<br />
{<br />
return myString;<br />
}<br />
set<br />
{<br />
myString = value;<br />
if(MyStringChanged!=null)<br />
MyStringChanged(value);<br />
}<br />
}
|
|
|
|
|
hi everybody,
i m creating a browser in 2005 .net using c#.i came across the problem.i want to open a new form on closing event of old form. New form has field userid n password,only after verifying valid user both form should be closed.if user is not valid then old form should not be closed.
if any idea then send me some clue if possible please send me source code in c#.
|
|
|
|
|
Show the new form in the onclosing event of the first one. After validating it close the new form and the old form will be closed too. If you want to cancel closing of old form have a look at the second argument of the onclosing event
|
|
|
|
|
You want people to provide credentials in order to close your app ?
Yeah, handle the onclosing event and set the properties of the event args to cancel the close if you need to.
Christian Graus - Microsoft MVP - C++
Metal Musings - Rex and my new metal blog
"I am working on a project that will convert a FORTRAN code to corresponding C++ code.I am not aware of FORTRAN syntax" ( spotted in the C++/CLI forum )
|
|
|
|
|
This is a question actually: if you want to connect more clients to a server using .NET remote, and you want them to interchange message using the server, how would u do that?
i already know how to send messages to the server using remote objects, but i don't know in what way will the server know from which client(ip address) it got the message, and how to send the message to a specific client...
that's what i mean by inter-client communication.
|
|
|
|
|
Hi all.
I have a windows service that inserts some messages in a database. Now, I need an interface so a user can see the process.
My first option was adding an interface to the service. Is that possible? I've been reading about that and is not very usual.
If not, the option would be creating another application that communicates with the service and shows the messages. In that case, how can I do that? Should I use Remoting? I'm not sure about how to get the messages from the service. My service is just a loop that listens to a socket and inserts the received messages in a database. If the service can have an interface, it would be as easy as showing a message in a control after each message processed.
Any ideas please?
Regards,
Diego F.
|
|
|
|
|
I'm sorry if this sounds stupid, but cant we filter datasets in a very simple and effective way??
Thanks a bunch guys.
Smile: A curve that can set a lot of things straight!
(\ /)
(O.o)
(><)
|
|
|
|
|
by creating Dataview from dataset u can filter the data
rahul
|
|
|
|
|
You can use select method or you might want to look at dataview class
|
|
|
|
|
hi
we have developed windows application with lots of controls. we are facing the problem with exceeding GDI counts. we tried lot of solution from the net but still the problem exist.
kindly direct us to right path or suggest any solution
prabu
|
|
|
|
|
i think proper disposal of objects can help u out
rahul
|
|
|
|
|
What sort of controls ? Are they on lots of forms ? Do you do any custom painting ? Do you load bitmaps or images anywhere ?
Your GDI count is increasing because you load a resource and do not call Dispose on the object that holds it, so it is never released ( well, it will be eventually ).
Christian Graus - Microsoft MVP - C++
Metal Musings - Rex and my new metal blog
"I am working on a project that will convert a FORTRAN code to corresponding C++ code.I am not aware of FORTRAN syntax" ( spotted in the C++/CLI forum )
|
|
|
|
|
we are using lots of usercontrols, and loading it dynamically!
though we dispose the usercontrols gdi count is not decrementing.
thanks for reply.
|
|
|
|
|
hi all,
i write this code to draw line by mouse and the drawline method is in the onPaint() method,this code is working properly but has two problems so is there any other idea to code it
private void mainScreen_MouseMove(object sender, MouseEventArgs e)<br />
{<br />
<br />
if (lineFlag == 1 && !(mLineBeginPnt.IsEmpty) && nextLineFlag == 1)<br />
{<br />
Graphics grfx = this.CreateGraphics();<br />
Pen pen = new Pen(mainScreen.DefaultBackColor, 2);<br />
userInterface.handleMouseMove(grfx, ref lastPntOfLine,<br />
ref lastPntCounter, pen, ref mLineEndPnt, mLineBeginPnt, e.Location);<br />
pen.Dispose();<br />
grfx.Dispose();<br />
Invalidate(drawingFrame);<br />
}<br />
<br />
}<br />
----------------------------------------<br />
public void handleMouseMove(Graphics grfx,ref Point lastPntOfLine,<br />
ref int lastPntCounter, Pen pen, ref Point mLineEndPnt, Point mLineBeginPnt,<br />
Point location)<br />
{<br />
if (lastPntCounter == 0)<br />
{<br />
lastPntOfLine = location;<br />
lastPntCounter++;<br />
}<br />
else<br />
grfx.DrawLine(pen, mLineBeginPnt, lastPntOfLine);<br />
mLineEndPnt = location;<br />
Pen p = new Pen(Color.Black, 2);<br />
grfx.DrawLine(p, mLineBeginPnt, mLineEndPnt);<br />
lastPntOfLine = location;<br />
grfx.Dispose();<br />
pen.Dispose();<br />
p.Dispose();<br />
<br />
}<br />
what i made in this code is that i determine the last line drawen by nouse by getting its begin and end points from line object that i have then draw this line by background color to hide it and draw new line with black color to seen by user
(this code is an alternative for using XOR mode, if any one know how to use it with drawing lines please tell me)
thanks
Generator
-- modified at 4:12 Tuesday 8th May, 2007
|
|
|
|
|
HexaDeveloper wrote: Graphics grfx = this.CreateGraphics();
You don't say what your problems are, but you should NEVER do this, unless you want to draw something that will immediately disappear. As soon as your window is obscured, your line will disappear, you should always draw your lines within the paint event of your form and call Invalidate() to force a paint event.
Christian Graus - Microsoft MVP - C++
Metal Musings - Rex and my new metal blog
"I am working on a project that will convert a FORTRAN code to corresponding C++ code.I am not aware of FORTRAN syntax" ( spotted in the C++/CLI forum )
|
|
|
|
|
hi ,
my problem is that i donot know how to use XOR mode in drawing line
Generator
|
|
|
|
|
hi 4 all
some problem occured when i try to connect existing file ( help file ) with my application
i hope any one to help me
** open help file from my application without open file dialog
thanxxxxxx
|
|
|
|
|
|
Do you have a help file and want to open it from your application using the appropriate program? If so use System.Diagnostics.Process.Start()
|
|
|
|
|
Dear All,
In vb.net we can give like this for getting illustrator application
appRef = CreateObject("Illustrator.Application")
in C#.net what we can give for getting illustrator application
Thanks in Advance
Dana
|
|
|
|