Click here to Skip to main content
15,892,161 members
Home / Discussions / C#
   

C#

 
Questionbase64 and UTF-8 encoding issue Pin
George_George22-Feb-09 3:09
George_George22-Feb-09 3:09 
AnswerRe: base64 and UTF-8 encoding issue Pin
Xmen Real 22-Feb-09 3:12
professional Xmen Real 22-Feb-09 3:12 
GeneralRe: base64 and UTF-8 encoding issue Pin
George_George22-Feb-09 3:22
George_George22-Feb-09 3:22 
GeneralRe: base64 and UTF-8 encoding issue Pin
Xmen Real 22-Feb-09 3:27
professional Xmen Real 22-Feb-09 3:27 
GeneralRe: base64 and UTF-8 encoding issue Pin
George_George22-Feb-09 20:32
George_George22-Feb-09 20:32 
QuestionSolitaire like card game Pin
nubbs22-Feb-09 3:01
nubbs22-Feb-09 3:01 
AnswerRe: Solitaire like card game Pin
Xmen Real 22-Feb-09 3:11
professional Xmen Real 22-Feb-09 3:11 
QuestionSecond form using accessors of first form to alter first form object properties problem Pin
Member 210292422-Feb-09 2:54
Member 210292422-Feb-09 2:54 
Hi there,
I've researched this for two days now and followed guide lines set down from sites such as MSDN, bytes.com, dotnetspider and many others but still no joy.

What I wish to do is have Form1 call Form2 where abouts on certain conditions in Form2 (user event say) a message is written to a text box in Form1. I can't get it to work. Here's some code
// Form1 bits
public class Form1
{
	private System.Windows.Forms.TextBox txtMainMessage;  // message area i want to write to. I tried as public modifier as well
	public Form1()
 	{
		// init components 
		// more house keeping
	}
        // This is public accessor I wish to access from form2
        // to write to txtMainMessage textbox. Apparently best practice
	public string WriteMainMessage
	{
		set
		{
			this.txtMainMessage.Text = value;
			MessageBox.Show("from set " + this.txtMainMessage.Text);  // This will display "from set This is accessor"
			this.txtMainMessage.Refresh();
		}
		get
		{
			return this.txtMainMessage.Text;
		}
         }
	button_click(args..)
	{
		//load form2
	}
}
// Here is Form2 part
public class Form2
{
 	private Form1 frm; // set member for form1 object. Tried as public as well
 	public Form2()
	{
		 // init components and stuff
 		frm = new Form1();   //instantiate our Form1 obj
	}
	button_click(args...)	// user event to generate message
	{
		frm.WriteMainMessage = "This is accessor";	// in vstudio drop down list shows WriteMainMessage as a property of Form1 frm
		MessageBox.Show("accessor says " + frm.WriteMainMessage);	// accessing get, displays "accessor says This is accessor"
	}
}

TextBox txtMainMessage in Form1 still will not display anything. There are no errors. Is there some redraw I'm missing? As mentioned I tried setting txtMainMessage as public modifier which Form2 could access its Text property directly. Still would not write to textbox. Just as experiment i set a button on Form1 to write to txtMainMessage, that worked (relief). Where does frm.WriteMainMessage in Form2 sit within scope of Form1 TextBox? I wrote a public method in Form1 which Form2 sends a message to. Method set text property of textbox to message, I displayed the contents of TextBox.Text and there was the message! So this.txtMainMessage.Text actually holds the value but will not draw it in the text box itself.

What do you feel I am missing here? Thank you in advance.
Anthony James Lawrence
AnswerEverything is working Pin
Xmen Real 22-Feb-09 3:07
professional Xmen Real 22-Feb-09 3:07 
GeneralRe: Everything is working Pin
Member 210292422-Feb-09 3:41
Member 210292422-Feb-09 3:41 
GeneralRe: Everything is working Pin
Member 210292422-Feb-09 3:43
Member 210292422-Feb-09 3:43 
GeneralRe: Everything is working Pin
Xmen Real 22-Feb-09 6:56
professional Xmen Real 22-Feb-09 6:56 
GeneralRe: Everything is working Pin
DaveyM6922-Feb-09 9:27
professionalDaveyM6922-Feb-09 9:27 
GeneralRe: Everything is working Pin
Member 210292422-Feb-09 19:11
Member 210292422-Feb-09 19:11 
GeneralRe: Everything is working Pin
DaveyM6923-Feb-09 1:38
professionalDaveyM6923-Feb-09 1:38 
Question[Message Deleted] Pin
Chetan Patel22-Feb-09 1:59
Chetan Patel22-Feb-09 1:59 
AnswerRe: Custom Window Control, The Control does not Repaint on Posision change of SCROLL Pin
Xmen Real 22-Feb-09 2:54
professional Xmen Real 22-Feb-09 2:54 
QuestionHow to add multiple controls at runTime ? Pin
hdv21222-Feb-09 0:52
hdv21222-Feb-09 0:52 
AnswerRe: How to add multiple controls at runTime ? Pin
Member 349379922-Feb-09 1:09
Member 349379922-Feb-09 1:09 
AnswerRe: How to add multiple controls at runTime ? [modified] Pin
Member 349379922-Feb-09 1:16
Member 349379922-Feb-09 1:16 
GeneralRe: How to add multiple controls at runTime ? Pin
hdv21222-Feb-09 1:30
hdv21222-Feb-09 1:30 
GeneralRe: How to add multiple controls at runTime ? Pin
dan!sh 22-Feb-09 1:52
professional dan!sh 22-Feb-09 1:52 
GeneralRe: How to add multiple controls at runTime ? Pin
ABitSmart22-Feb-09 2:09
ABitSmart22-Feb-09 2:09 
AnswerRe: How to add multiple controls at runTime ? Pin
Luc Pattyn22-Feb-09 2:27
sitebuilderLuc Pattyn22-Feb-09 2:27 
QuestionCompile error: Using strings inside Struct with LayoutKind.Explicit Pin
Member 349379921-Feb-09 23:57
Member 349379921-Feb-09 23:57 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.