|
Looking for code to pass information from Form2.textbox1 back to Form1.label1
Process - Press Form1.button1 to show Form2,
Enter information into Form2.textbox1,
Press Form2.button1 to display information from Form2.textbox1 to Form1.label1.
Thnaks in Advance!
Form1 consists of <startup form="">
Label1
Button1
For2 consist of
textbox1
Button1
|
|
|
|
|
Pass an instance of Form1 to constructor of Form2 when instanciating, something like this:
Form2 frm2 = new Form2(this);
Then in Form2 , you have access to all public and internal variables of Form1 , so you can define a property of your Lable1 in Form1:
public string MyLable{
get{
return this.Lable1.Text;
}
set{
}
this.Lable1.Text = value;
}
and in Form2 , when the user clicks on Button1 , do this:
frm1.MyLable = TextBox1.Text;
frm1 is a variable of type Form1 that holds a refrence to Form1 which has been passed to constructor of Form2.
abcdabcdabcdabcda
Don't forget, that's Persian Gulf not Arabian gulf!
Why do we close our eyes, when we dream?, When we cry?, When we imagine?, When we kiss?, Its because the most beautiful things in the world are unseen
Murphy: Click Here![^] I'm thirsty like sun, more landless than wind...
|
|
|
|
|
Google on "Mediator pattern" and "MVC" (or "Model-View-Controller"). If you learn how to use these patterns, you'll never get stuck like this again; your code won't need tricks like passing a form to another form. I recommend "Design Patterns" by the Gang of Four.
I'm not saying maysam's advice is bad, but as you construct more and more complicated GUIs, you'll find that it's harder and harder to deal with the complexity you create by hard-wiring things together. Design patterns are over-applied and otherwise screwed up by morons who haven't taken the time to really learn how to use them, which has given them a bad rap. In my experience, though, Mediator and MVC are the most important things to know when programming client-side rich GUI applications. Everything else is a little bit of learning involving threads that's easy to accomplish, and rote memorization of properties of controls and the like.
|
|
|
|
|
Im creating a desktop ticker in C# that I wont to be displayed running along active applications, on the right hand side of the screen.
My question is that when I launch my ticker, how do i adjust currently running apps (e.g. IE/Notepad ..etc) so that they maximize around my ticker, so that my ticker occupies the left part of the screen.. Thx
|
|
|
|
|
I am creating a base form that has a private datagrid that is bound to a dataset. This datagrid uses the paint event as well. I have another form that is inheriting this base form (both forms are in the same project folder). Everything runs perfectly. But, when I bring up the child form in design view, I get the message "DataGrid received an exception at design time. Please reset the DataSource and DataMember property on the grid". Has anyone encountered this message? Also, does anyone know a good reference for design time exceptions? Thanks.
|
|
|
|
|
I've managed to redraw the layout of a form to the desired effect (by rebuilding the region) but so far have been unable to figure out how to add a border around it. Is there an easy way? Would anyone have any brief examples?
Cheers.
|
|
|
|
|
This is pretty vague. What region? Do you mean you've masked the window frame, thus creating a non-rectangular region? Please be more specific.
Microsoft MVP, Visual C#
My Articles
|
|
|
|
|
Yes, sorry. That is exactly what I meant. I've basically masked the original form such that the form now has rounded corners. Nothing amazing I know but i'm just learning. The form has border style set to none and then rounded. The only problem is that if this form is on top of another one then it all just blends in and looks as one. I thought if I could draw a border around the rounded form then it would make things look more separate. Ta.
|
|
|
|
|
You would have to draw them yourself. The only APIs for helping you draw rectangular regions (see the ControlPaint class - even the Windows APIs only help you do the same).
Typically, you make a non-rectangular client area using an image. You could do the same here. Either use or generate an image (if you generated an image, you could use the SystemColors read-only properties to generate an image using the system colors) with an alpha channel and rounded edges. You set that to the Form.BackgroundImage property and set the TransparencyKey if you want to clip a certain color. You could also use an image without an alpha channel (or even with, it just wouldn't make any difference in this case) and use the same region to clip (not mask) the area you want, having rounded, 3D corners within that region. This would work on all .NET-supported Windows platforms, perhaps even some Mono platforms (depending on what window manager / toolkit is used for Windows Forms). Using the alpha channel or color key only works in Windows 2000 and newer.
Microsoft MVP, Visual C#
My Articles
|
|
|
|
|
hi, I use the crystal report in .net environment.
I have 2 questions:
1)If a report has many detailed records so that they go beyond one page. I want the header (Group By section) to show on the top of both pages. How can I do it?
2)I want each group to start a new page, so I checked New page after choice + Suppress blank section choice in the group footer section, but emputy page will still be there at the end of the report, how can I eliminate the emputy page?
|
|
|
|
|
Chris# wrote:
1)If a report has many detailed records so that they go beyond one page. I want the header (Group By section) to show on the top of both pages. How can I do it?
This content should go in the "Page Header" section.
Chris# wrote:
I want each group to start a new page, so I checked New page after choice + Suppress blank section choice in the group footer section, but emputy page will still be there at the end of the report, how can I eliminate the emputy page?
Experiment with "New Page Before", try it in different sections, I think it will give you the desired effect.
HTH
R.Bischoff .NET, Kommst du mit?
Great Freeware -> Abilon - Rss Reader | Zip Genius | SmartFTP
|
|
|
|
|
create a fillschema a dataset
I create a SYBASECOMMANDBUILDER (from DDTEK Sybase Driver)
I create a row from the dataset
I fill the row with data
I add the row back to the datatable
[rowstate is now UNCHANGED]
I make a change to the newly added row
[rowstate is still UNCHANGED]
Of course the following update command returns zero, since there are no rows that do not have a status of "UNCHANGED". Can someone explain to me what I did wrong? datarow adds and changes should change the rowstate to Added and Modified respectively. Thanks in advance
Have a blessed day in Messiah EYAWHOOSHUA!
|
|
|
|
|
Make sure you don't call AcceptChanges on either the DataSet or the DataTable . To note, a DataAdapter will call this after updating your data store (ex: database).
Microsoft MVP, Visual C#
My Articles
|
|
|
|
|
Also the rowstate changes as soon as I create the commandbuilder. If I call the command builder before adding the row(as in my example), then the rowstate stays Unchanged.
Have a blessed day in Messiah EYAWHOOSHUA!
|
|
|
|
|
|
|
|
A quick FYI for ya: Microsoft is considering deprecating, changing the name of, or possibly removing the ICloneable interface in version 2 of the .NET framework. This is due to the ambiguity of whether ICloneable objects implement deep or shallow copies. Microsoft is recommending that library designers do not implement ICloneable.
#include "witty_sig.h"
|
|
|
|
|
That's not surprising. Thanks for the info.
BTW, are they going to deprecate overloading operator == for the same reason?
|
|
|
|
|
No, or at least I've not heard anything as such. Whether some object "equals" something is up to the object designer. That differs from ICloneable because of the ambiguity of the type of cloning. So I'd say they'll probably keep it.
#include "witty_sig.h"
|
|
|
|
|
Hi,
I'm wondering if there can be any problem related to using a datadrig bounded to a dataset that is updated by temporary methods called from different timers:
<br />
OnTimer1 () { put data into data set table 1}<br />
<br />
OnTimer2 () { put data into dataset table 2 }<br />
<br />
Datagrid uses dataset to show data inserted by the two timers.<br />
After a few updates on the dataset, de application throws a System.NullReferenceException in system.windows.forms.dll (Object reference not set to an instance of an object).
Could it be that I'm using DataView's to search for records to update in the timers? Well this as proved to be a great headache to me, I appreciate your atention.
Best Regards,
Anfernius
|
|
|
|
|
Using a DataView is not a problem. With a lack of more detailed information, it's impossible to help you. You need to debug your code: step through your code and find where the NullReferenceException is being thrown.
Also, when a NullReferenceException is thrown, this often points to badly written code. There is no excuse for this exception - always check your variables to make sure they're not null before calling methods on them. If you're expecting data in a particular DataTable within your DataSet , for example, and no data was returned, that DataTable reference could be null (depending on whether or not the DataSet was filled with schema information). Calling a method on that DataTable without checking for a null reference would throw a NullReferenceException . Checking the return value, using a typed DataSet , and programmatically adding a new DataTable with the appropriate name would get rid of this problem.
Microsoft MVP, Visual C#
My Articles
|
|
|
|
|
This Exception may be thrown when you try to change data in the same time as DataGrid reads them. Try to suspend binding before changing data from timer thread, or try to use Invoke method of the datagrid and then call your changing methods.
I am less sure the 2nd method, but it may work.
h.
|
|
|
|
|
Hi,
I have a text box on my form . I want to move the text box to the position where the user clicks. So I kept the location in variables and I am getting the coordinates of mouse click. How do I repaint the form so that the text box appears at the mouse click position.
Karteek
|
|
|
|
|
So, what is your problem? Just set the new X and Y values of the textbox and call the Refresh () method of the form if required.
Don't forget, that's Persian Gulf not Arabian gulf!
Murphy: Click Here![^] I'm thirsty like sun, more landless than wind...
|
|
|
|