|
|
thanx for ur help
ill check this links and c
|
|
|
|
|
|
Hello,
I am at the moment not so experienced with C# but I am learning.
I have the following problem.
On Form1 i have 1 textbox and 1 button. When I press the button it opens a send form (Form2).
There is also one button on Form2, when I press it, the value of the textbox on Form1 needs to change.
Is this possible?
I try to make textbox public but than i need a reference to the Form1 object.
This is ofcourse simplified representation of the problem i have.
If I do this on Form2:
Form1 form1 = new Form1();
form1.textbox.text = "test";
Nothing happens, and i suppose this is normal, because you create a new instance.
What i want to do is on Form2:
Form1.textbox.text = "test";
At compile I receive the following msg: An object reference is required for the nonstatic field, method or property.
I don't think that i have to make the textbox public static. I am a bit lost in this situation, is someone there who can halp me and clear things out.
Thanks
|
|
|
|
|
What you can do is pass the reference of Form1 to the Form2 constructor.
Then keep the instance in a global variable and you can set the text whenever you want.
The Textbox object would also need to be made public, or (better way) have a property on the Form1 class that will set the text when called.
Cheers,
Simon
sig :: "Don't try to be like Jackie. There is only one Jackie.... Study computers instead.", Jackie Chan on career choices.
article :: animation mechanics in SVG blog:: brokenkeyboards "Most of us are programmers, but a few use VB", Christian Graus
|
|
|
|
|
Thanks for the fast reply.
Still for me it is difficult and i feel that i am lost.
Ofcourse i can make a public variable and when I close Form2, Form1 becomes active i can set the Textbox with the variable. But i don't like this work arround method.
Can someone show me a simple code example maybe?
Thanks.
|
|
|
|
|
Hellow,
I found the solution to my problem.
I resume here for in case other people were strugling with the same problem.
Form1:
make textbox1 to public
private void button1Click(object sender, System.EventArgs e)
{
Form2 _form2 = new Form2(this);
_form2.Show();
}
Form2:
private Form1 _form;
public Form2(Form1 form)
{
InitializeComponent();
_form = form;
}
So on Form2 you are able to do this: _form.textbox1.Text = "TEST";
You will see that the value in Form1 textbox1 will change to TEST
Greetings.
|
|
|
|
|
hi friends,
how do i create graphs and charts in c#. what is this .net charting?
|
|
|
|
|
There's Dundas Charts which, costs alot, and then there's Zed Graph, which is FREE.
/\ |_ E X E GG
|
|
|
|
|
how do i get zed graph and how to use it?
|
|
|
|
|
|
hi
i use a requer validator to control a textbox in a web page.
it works correctly on local but when i upload it to server the validator dosnt works.
whats the problem?
thanks
|
|
|
|
|
The one time I used validators on a website (which was .NET Beta 2) I had to copy a java script into a very specific location on my webserver (by hand) before things would work.
So much for the much-aclaimed "just xcopy your web now".
There are 10 kinds of people in the world.
Those that read binary...
...and those who don't.
|
|
|
|
|
|
The validators use a java script file that must be copied into the IIS website. Copying your application to the webserver does not copy the java script.
It took me a search of my entire machine to find the bloody thing and then I had to have my application crap out doing remote debugging to find out what directory to put the javascript file into.
Does this help clear up the confusion? ie: You have lots of digging searching and debugging to get your validators running.
There are 10 kinds of people in the world.
Those that read binary...
...and those who don't.
|
|
|
|
|
Hi All,
wie übergibt man eigentlich einen String der Steuerzeichen enthält an eine Oracletabelle, quasi an einen VARCHAR2?
Folgende Source fürht imme rzu einem Fehler, weil auch Steuerzeichen in den Strings HighTeach und LowTeach sein können!
qrystr = "INSERT INTO ruest_teach(RT_RK_ORGE_NR, RT_RK_MODELL_NR, RT_TEACH_H, RT_TEACH_L) VALUES(" + this.RK_ORGE_NR+ ", '" + this.RK_MODELL_NR +"', '" + HighTeach + "', '" + LowTeach + "')";
LG eXi
|
|
|
|
|
Hast Du in den Foren schon mal einen anderen deutschsprachigen Artikel gesehen? Bitte halte Dich an die Regeln hier und poste wenn dann in englisch!
Trotzdem zu Deiner Frage: Such mal nach "parameterized queries", da findest Du, wie es vernünftig gemacht wird.
mav
|
|
|
|
|
Hi,
problem is the following:
I have a program sending a ButtonClick Message to another app so that this app opens a modal dialog. To achieve this I use PInvoke and the function SendMessage(hWnd, BM_CLICK, 0, 0) . This code works, but when the Button is clicked and the modal dialog opens, my program (the one, which sent the message) stopps running, means no code after calling SendMessage is executed (can clearly see this in the debugger). When I manually close the opened dialog in the other app my program runs on. I can't explain myself this behaviour because all other programs run on properly. For example I could write another program, which runs the code, which should be executed after SendMessage. This program would run without any problems. Can anyone explain this to me? Any solutions to let my program work on?
Thanks
|
|
|
|
|
The SendMessage function calls the window procedure for the specified window and does not return until the window procedure has processed the message.
To send a message and return immediately, use the SendMessageCallback or SendNotifyMessage function.
www.troschuetz.de
|
|
|
|
|
...or PostMessage or PostThreadMessage
mav
|
|
|
|
|
THX for the completion
and congratulations for beating me by seconds on the other thread
www.troschuetz.de
|
|
|
|
|
Only because my answer was much shorter
|
|
|
|
|
Thanks guys. Don't know why I didn't investigate on that.
|
|
|
|
|
Hi
Is it possible to identify the Cursor postion inside the textbox not the mouse pointer.If so how to access that?? Plz Help
Regards
Deepak.S
|
|
|
|
|
TextBox.SelectionStart might be what you're looking for.
Regards,
mav
|
|
|
|