Hello DaniWeb community! I am trying to learn c# by going through a few tutorials on how to make an RPG game game using windows form, but I cant seem to get the hang of making the create a character screen. I tried to get the value of a track bar to appear in a label next to the track bar, and automatically set itself when the track bar scrolls, but I could not figure out how to find the value of a track bar and set it to a variable to set to a label. I also tried having a label in between a "-" and "+" button, and have the label increase by 1 or decrease by 1 every time a user presses a button, then grab the value of the label and store it in a variable. This also did not work for me because I could not make the label an integer, and have it automatically refresh every time a user presses a button. I also tried to make a combo box with value 1-10, and have a label on the side with the maximum amount of points to spend, and have it subtract from the value of the combo box, and have it automatically refresh when a value is chosen.

The main question I have is I am wondering how to do any of the following examples I have given. I would put in my code, but I do not have any to show right now, as in I feel I was just spitballing the code and it is not relevent, so I just have http://imgur.com/eEg0Fq4 at the moment, because I was trying to change the label values if a class was chosen from the combo box, but even then I was having a hard time.

The UI was made from the designer in the windows form, and I think I have a hard time getting a value from a form component and storing it in a value, and automatically refreshing the label every time something is chosen.

Any help is appreciated,
Kyle

I would suggest that you do not try to store all your information in labels, but rather have seperate variables that control the amount of each stat that your character has and then display those values in the labels.

I tossed together a quick example of how you can use buttons to increase and decrease the stats for your character. I am sure there are better ways of coding this but this should get you on track and going.

UI is here - http://i.imgur.com/zS0hM22.png

using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;

namespace DaniRPG
{
    public partial class Form1 : Form
    {
        Player me;
        Int32 remainingPoints;

        public Form1()
        {
            InitializeComponent();
        }

        private void Form1_Load(object sender, EventArgs e)
        {
            me = new Player();
            remainingPoints = 20;

            lblAgiPts.Text = me.Agility.ToString();
            lblIntPts.Text = me.Intelligence.ToString();
            lblStrPts.Text = me.Strength.ToString();
            lblStamPts.Text = me.Stamina.ToString();
            lblRemainingPts.Text = remainingPoints.ToString();
        }

        private void btnStrInc_Click(object sender, EventArgs e)
        {
            if (remainingPoints > 0)
            {
                me.Strength++;
                remainingPoints--;
                lblStrPts.Text = me.Strength.ToString();
                lblRemainingPts.Text = remainingPoints.ToString();
            }
        }

        private void btnStrDec_Click(object sender, EventArgs e)
        {
            if (me.Strength > 0)
            {
                me.Strength--;
                remainingPoints++;
                lblStrPts.Text = me.Strength.ToString();
                lblRemainingPts.Text = remainingPoints.ToString();
            }
        }

        private void btnAgiInc_Click(object sender, EventArgs e)
        {
            if (remainingPoints > 0)
            {
                me.Agility++;
                remainingPoints--;
                lblAgiPts.Text = me.Agility.ToString();
                lblRemainingPts.Text = remainingPoints.ToString();
            }
        }

        private void btnAgiDec_Click(object sender, EventArgs e)
        {
            if (me.Agility > 0)
            {
                me.Agility--;
                remainingPoints++;
                lblAgiPts.Text = me.Agility.ToString();
                lblRemainingPts.Text = remainingPoints.ToString();
            }
        }

        private void btnIntInc_Click(object sender, EventArgs e)
        {
            if (remainingPoints > 0)
            {
                me.Intelligence++;
                remainingPoints--;
                lblIntPts.Text = me.Intelligence.ToString();
                lblRemainingPts.Text = remainingPoints.ToString();
            }
        }

        private void btnIntDec_Click(object sender, EventArgs e)
        {
            if (me.Intelligence > 0)
            {
                me.Intelligence--;
                remainingPoints++;
                lblIntPts.Text = me.Intelligence.ToString();
                lblRemainingPts.Text = remainingPoints.ToString();
            }
        }

        private void btnStamInc_Click(object sender, EventArgs e)
        {
            if (remainingPoints > 0)
            {
                me.Stamina++;
                remainingPoints--;
                lblStamPts.Text = me.Stamina.ToString();
                lblRemainingPts.Text = remainingPoints.ToString();
            }
        }

        private void btnStamDec_Click(object sender, EventArgs e)
        {
            if (me.Stamina > 0)
            {
                me.Stamina--;
                remainingPoints++;
                lblStamPts.Text = me.Stamina.ToString();
                lblRemainingPts.Text = remainingPoints.ToString();
            }
        }
    }

    public class Player
    {
        public Int32 Stamina, Intelligence, Strength, Agility;

        public Player()
        {
            Stamina = 5;
            Intelligence = 5;
            Strength = 5;
            Agility = 5;
        }

    };
}
This question has already been answered. Start a new discussion instead.