Connect with Facebook Lost Password?


Go Back   CodeCall Programming Forum > Software Development > C# Programming

C# Programming C# (pronounced C-sharp) is a new object oriented language from Microsoft and is derived from C and C++. It also borrows a lot of concepts from Java too including garbage collection.

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old 09-02-2008, 03:27 AM
Newbie
 
Join Date: Sep 2008
Posts: 6
Rep Power: 0
bogus is an unknown quantity at this point
Default Win Forms question

Hello,
Consider a WinForm A and a WinForm B. I want to click a button from B and write something in a textBox from A. Can you help me with that?
Thanks
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #2 (permalink)  
Old 09-02-2008, 07:27 AM
Xav's Avatar   
Xav Xav is offline
Code Slinger
 
Join Date: Mar 2008
Location: The North Pole
Posts: 13,210
Blog Entries: 13
Rep Power: 105
Xav has much to be proud ofXav has much to be proud ofXav has much to be proud ofXav has much to be proud ofXav has much to be proud ofXav has much to be proud ofXav has much to be proud ofXav has much to be proud ofXav has much to be proud of
Send a message via MSN to Xav
Default Re: Win Forms question

Do you have a reference to the form instance from WinForm B? If not, then use the static keyword on the method declaration that writes the text in WinForm A.
__________________

Quote:
Originally Posted by Jordan View Post
Good members, like yourself, stick around and post for ages to come!
Mr. Xav | Blog | Forums
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #3 (permalink)  
Old 09-02-2008, 11:36 AM
Newbie
 
Join Date: Sep 2008
Posts: 6
Rep Power: 0
bogus is an unknown quantity at this point
Default Re: Win Forms question

It's like this, i got my main form..FormA..i push a button and create a FormB (FormB x =new FormB(); x.ShowDialog(); ) now i want to push a button from x and write something in a textbox from my main form..there is no instance of FormA
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #4 (permalink)  
Old 09-02-2008, 12:26 PM
Xav's Avatar   
Xav Xav is offline
Code Slinger
 
Join Date: Mar 2008
Location: The North Pole
Posts: 13,210
Blog Entries: 13
Rep Power: 105
Xav has much to be proud ofXav has much to be proud ofXav has much to be proud ofXav has much to be proud ofXav has much to be proud ofXav has much to be proud ofXav has much to be proud ofXav has much to be proud ofXav has much to be proud of
Send a message via MSN to Xav
Default Re: Win Forms question

In FormA, try writing a method like this in Form A:
Code:
public static WriteText(string TheText)
{
 textBox1.Text = TheText;
}
Then, in Form B, try this:
Code:
FormA.WriteText("Hello world");
I dunno if it works or not? The "static" keyword should do the trick.
__________________

Quote:
Originally Posted by Jordan View Post
Good members, like yourself, stick around and post for ages to come!
Mr. Xav | Blog | Forums
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #5 (permalink)  
Old 09-02-2008, 01:27 PM
Newbie
 
Join Date: Sep 2008
Posts: 6
Rep Power: 0
bogus is an unknown quantity at this point
Default Re: Win Forms question

thanks for your reply Xav i will see try and let you know about the results
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #6 (permalink)  
Old 09-02-2008, 01:30 PM
Xav's Avatar   
Xav Xav is offline
Code Slinger
 
Join Date: Mar 2008
Location: The North Pole
Posts: 13,210
Blog Entries: 13
Rep Power: 105
Xav has much to be proud ofXav has much to be proud ofXav has much to be proud ofXav has much to be proud ofXav has much to be proud ofXav has much to be proud ofXav has much to be proud ofXav has much to be proud ofXav has much to be proud of
Send a message via MSN to Xav
Default Re: Win Forms question

Ok.
__________________

Quote:
Originally Posted by Jordan View Post
Good members, like yourself, stick around and post for ages to come!
Mr. Xav | Blog | Forums
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #7 (permalink)  
Old 09-02-2008, 02:00 PM
Newbie
 
Join Date: Sep 2008
Posts: 6
Rep Power: 0
bogus is an unknown quantity at this point
Default Re: Win Forms question

In this context:

public static WriteText(string TheText)
{
textBox1.Text = TheText;
}

textBox1 seems not be visible
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #8 (permalink)  
Old 09-03-2008, 01:48 PM
Xav's Avatar   
Xav Xav is offline
Code Slinger
 
Join Date: Mar 2008
Location: The North Pole
Posts: 13,210
Blog Entries: 13
Rep Power: 105
Xav has much to be proud ofXav has much to be proud ofXav has much to be proud ofXav has much to be proud ofXav has much to be proud ofXav has much to be proud ofXav has much to be proud ofXav has much to be proud ofXav has much to be proud of
Send a message via MSN to Xav
Default Re: Win Forms question

You put that on Form A, which contains the textbox.
__________________

Quote:
Originally Posted by Jordan View Post
Good members, like yourself, stick around and post for ages to come!
Mr. Xav | Blog | Forums
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
Reply



Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Fading Forms in VB.NET Xav VB Tutorials 19 08-16-2008 08:42 AM
Newbe C# Platform question cob98tp C# Programming 28 07-30-2008 08:01 AM
Using variables in different forms question skilletsteve Visual Basic Programming 2 08-31-2006 10:39 AM
Question about Form's On_Closing event hoser2001 C# Programming 3 08-22-2006 07:25 AM
Windows Forms MDI question. hoser2001 C# Programming 10 08-11-2006 06:36 PM


All times are GMT -5. The time now is 08:20 PM.

Freelance Jobs

XML/XSL: Need code for Book with Chapers using XML
Create an XML file for a book of your creation, and a basic CSS file that will format it to display ...
Earn: $40.00


C++/C: Simple firework cue sequencer
What I require is a rework of a simple cue sequencer. I have a piece of hardware (an Arduino boar...
Earn: $50.00


HTML/XHTML: Menu Rework - ASCIIBin
I'm placing this in the HTML/XHTML section of the Freelance site but you are not limited to HTML. Wh...
Earn: $20.00



CodeCall Goal

Goal #1: 1,000 Blogs
Goal #2: 1,000 Wiki Pages
Goal #3: 300,000 Posts
Goal #4: 20,000 Threads
Done: 30%, 23%, 55%, 75%

Ads