|
why a delegate? why not a property?
V.
I found a living worth working for, but haven't found work worth living for.
|
|
|
|
|
V. wrote: why a delegate? why not a property?
Loose coupling - So the forms don't have to know about each other.
|
|
|
|
|
As well as loose coupling, a delegate will allow a value to be sent between forms that are both active ( if form2 is modeless and form1 needs to update itself right away )
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 )
|
|
|
|
|
' define
public int n
'on top of page in form1
|
|
|
|
|
bad idea, it's against incapsulation rules. You should use a property for that
V.
I found a living worth working for, but haven't found work worth living for.
|
|
|
|
|
And make the property read only, or you break encapsulation just the same
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 )
|
|
|
|
|
I tend to disagree.
Suppose I have a variable distance (integer)
A distance can never be smaller then 0.
If I make my variable public, you can set it to what integer you like even < 0.
With a property you could build in a check.
set{<br />
if(value >= 0){<br />
distance = value;<br />
}<br />
else{<br />
distance = 0;<br />
}<br />
}
|
|
|
|
|
you can write a property.
public DateTime returnN{<br />
get{<br />
return n;<br />
}<br />
}
if your object is still valid, you can get the value by doing datetime n = form1.returnN;
A static variable is not suitable for this and neither is making 'n' public in Form1.
good luck
V.
I found a living worth working for, but haven't found work worth living for.
|
|
|
|
|
|
hi!!
i had been refering to article 'passing values betn forms'.
I tried from it, but still i cant pass my variable from form1 to form2.
I m getting error on passing my variable to the other form's variable.
i have used the object approach from that article :
http://www.codeproject.com/useritems/pass_data_between_forms.asp
Objects of forms are created properly.
This i have written in form1 :
p = ((form1)log).n;
// log is object of form2.
//variable 'n' i have to bring from form2,which contains a date from query fired.
but i m getting error :
'Object reference not set to an instance of an object.'
It would be v.nice if u could help on it.
Thanx.
-- modified at 6:20 Wednesday 21st February, 2007
|
|
|
|
|
I already explained exactly why you are unable to access the member, in your previous thread about the same thing.
If you can't keep your question in one thread, at least read the replies you get in the threads.
---
single minded; short sighted; long gone;
|
|
|
|
|
Hi, I am writing an application that will use textbox's in specific locations on the design form which i want to use which will print onto a document. While i am new to the printing functions of C# (as in looked at them for the first time lasst night ) I do not seem to be able to find many useful resources on printing in C# and was hoping someone could recommend a good resource which could help. I have done the basic tutorials, printing etc but nothing seems to cover printing from text box's at specific locations. These locations will be fixed so if i could just specify these to the printing class that would be great to, but my question is how do i do this as the area's on the form's I wish to print to are fixed on the A4 paper?
Many thanks for any help or recomendations of where i can find help.
|
|
|
|
|
hi
how can i have a list view control with combobox for one of the columns?
thanks
|
|
|
|
|
hi,
For my project i created a window control in Dot.Net. This control is having RichTextBox. I am using this control in web page. The problem i am facing is that all the formatting of richtextbox gets cleared when it lost and got focus.
-- modified at 3:52 Tuesday 20th February, 2007
|
|
|
|
|
i need to create custom textbox that after 3 decimal move ayutomatic to next control i have no probelm in code that make textbox apply only 3 decimal but iwant it to move automtic to next control with next tabindex for example if my textbox have tabindex 7 after 3 decimal move to control with tabindex 8 i can make it like this
[textbox2.focus() ]
but i want code in custome control to detected next tabindex and focus on that control automatic
thanks
ma_refay
|
|
|
|
|
Hello,
I don't think that it's the most elegant solution, but try this:
SendKeys.Send("{TAB}");
This will send a keyboard input (in this case TabKey) to the focused Control.
Hope it helps!
All the best,
Martin
|
|
|
|
|
Take a look at the Control.SelectNextControl method.
"Programming today is a race between software engineers striving to build bigger and better idiot-proof programs, and the Universe trying to produce bigger and better idiots. So far, the Universe is winning." - Rick Cook www.troschuetz.de
|
|
|
|
|
I am working on the C# code.
I am presently using the 'this.Close()' when the user clicks on the 'Done' button on the form, but my application is crashing at this point.
Is there someway by which I can close the form other than 'this.Close()' ?
I tried using 'this.Dispose()', but it closes the application at some other point.
Can you please help
|
|
|
|
|
Hello,
ArchaBhandare wrote: but my application is crashing at this point
What happens? (Which exception is thrown?)
Are there some cyclic handlers (for example timers) programmed in your forms code?
All the best,
Martin
|
|
|
|
|
The Exception message is as follows
"An unhandled exception of the type 'System.MissingMethodException' occurred in System.Windows.Forms.dll"
I tried replacing the dll file, but it still crashes at 'this.Close()'. I have upgraded by device. Still the issue occurs.
The best thing is that it works for all other forms, only for this particular form, the 'this.Close()' gives an exception.
If I comment out this line of code and have a this.Dispose() instead, the application does to crash but closes automatically at some other point.
|
|
|
|
|
In form1,i defined it like :
namespace WindowsApplication1
{
public partial class form1 : Form
{
public DateTime n;
SqlConnection conn = new SqlConnection("Data Source=PROGRAMER;Initial Catalog=....");
.....
}
In form2,i made object of form1:
System.Windows.Forms.Form form1_ = new form1();
string d = form1_.n;
-- BUT it is giving error on 'n' here, 'n' doesnot come on click of'.' after form1_
I hav used it like this in form1:
private void button1_Click(object sender, EventArgs e)
{
conn.Open();
string strQury = "";
strQury = "insert into dashboarddealerlogin (logoutdatetime) values '(" + DateTime.Now + ")'";
SqlCommand cm = new SqlCommand(strQury, conn);
n = Convert.ToDateTime(cm.ExecuteScalar());
}
Is my global declaration of 'n' still not proper?
Thank You.
Nekshan.
-- modified at 2:48 Tuesday 20th February, 2007
|
|
|
|
|
'all things is all right .I THINK U Assign n as date and here u declare string.so it might get error.
'string d = form1_.n;
' used like this
datetime n = form1.n;
'& u used from1 is the name of form right?
|
|
|
|
|
datetime n = form1.n;
-- Not Working:error on 'n'.
Nekshan.
|
|
|
|
|
I see three errors in your code.
1. You have declared the reference form1_ as a reference to a Form object, not a form1 object. Therefore you only have access to the members of the base class, none of the members of the inherited class.
2. You are creating a completely new instance of form1 , that means that it's separate from the instance that already exists. This in turn means that the n member has not been set for that instance.
3. You are executing an insert query and expect it to return data. The result from an insert query is empty, so the ExecuteScalar method will return null. This will be converted to DateTime.MinValue by the Convert.ToDateTime call.
---
single minded; short sighted; long gone;
|
|
|
|
|