Click here to Skip to main content
14,386,394 members
Rate this:
Please Sign up or sign in to vote.
See more:
Hi, my first post here, hopefully people will be able to help me with this, i'm a total noob at C# so totally need spoon feeding. SO let me set up what I have done so far..

Form1 is my title screen.
Form2 is my main game screen where interactions are done via mouse clicking things on the screen.
Form3 is set up as a side window that has a picturebox and two labels set up.

so.. in form 2 i want to click a picture, (that's acting as a button cos it has an image of a character in there), and I want that click to make changes to Form3 in 3 ways...

Display the face picture of that person in the picture box,
The one label to display that characters name.
The other label to display any text I type in the code for it to display.

Think kinda like an RPG when you walk up to an NPC and talk to them, a dialogue box pops up with their face picture there, name displayed, and then whatever they say.

I've tried for about 7 hours now to figure it out but well.. i'm not one for quitting but my patience is running very low after many hours of being stuck on the same thing, so any suggestions on how I achieve this please in the easiest way possible for me to understand?

Thanks

What I have tried:

I've tried way too many YouTube guides and guides off websites to list here.
Posted
Updated 19-Apr-19 4:41am

1 solution

Rate this:
Please Sign up or sign in to vote.

Solution 1

There are several ways to do it, the simplest is to make the controls on your forms Public instead of Private in the Designer, but this is considered bad practice.

You can find another solution here: How to change text in a textbox on another form in Visual C#? - Stack Overflow[^]
   
Comments
Member 14176556 19-Apr-19 9:58am
   
thanks, i will give that linked guide a go and see how it goes.. will reply shortly no doubt.
Member 14176556 19-Apr-19 10:22am
   
well i tried that code, the first lot of it seems to work fine but i have an isse with the one line of code..

form2.TextBoxValue = "SomeValue";

I gather the "somevalue" is where I would put my text I want displayed in the label on form3 but the part of the code that's underlined red is TextBoxValue .. not sure why its throwing me that error.
RickZeeland 19-Apr-19 16:13pm
   
Make sure you have the property in Form2:
public string TextBoxValue
{
get { return textBox1.Text;}
set { textBox1.Text = value;}
}
Member 14176556 20-Apr-19 6:53am
   
yeah, I couldn't get it working and have even scoured the internet and tried about 30 different guides, and god knows how many you tube tuts. In that code it says textBox1 .. i'm not using text boxes i'm using labels to display text.
RickZeeland 20-Apr-19 10:25am
   
Glad you solved it, missed the fact that you were using labels :)

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)




CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100