Nigel Alford

Nigel Alford

  • NA
  • 5
  • 2.1k

c# newbie with null reference error

Jun 11 2011 12:48 PM
I apologize in advance if this has been answered in a previous forum or post. I'm new to c# and my common problem regards null reference, normally I solve it but I'm stuck on this one.

Backstory: this is a windows mobile application and this form needs to take input from combo box and four text boxes and create a name based on user input.

I'm guessing that I need to reference the name of the string to correct this, but I'm unsure of if that's true and how my brain has taken the rest of the day off. I've underlined the line that throws the null reference exception, Thanks in advance

namespace ElevationPoint

{

    public partial class frmnewelevation : Form

    {

        public static frmsplitscreen staticsplitscreenForm = null;


        private string name1;


        public string Name1

        {

            get { return name1; }

            set { name1 = value; }

        }


        public frmnewelevation()

        {

            InitializeComponent();

        }


        public frmnewelevation(FormInfo info)

        {

            InitializeComponent();


            DIVBOX.SelectedItem = info.div;

            PreBox.Text = info.pre;

            SufBox.Text = info.post;

        }


        private void saveData()

        {

            throw new NotImplementedException();

        }


        private void MessageBox(string p)

        {

            throw new NotImplementedException();

        }


        private void mainmenu_Click(object sender, EventArgs e)

        {

            frmmainmenu.staticmainmenuForm.Show();

        }


        private void mbNext_Click(object sender, EventArgs e)

        {

            FormInfo info = new FormInfo();

            info.div = DIVBOX.SelectedValue.ToString();

            info.pre = PreBox.Text;

            info.post = SufBox.Text;


            this.name1 = DIVBOX.SelectedValue.ToString() + PreBox.Text + SufBox.Text + HIGHMPTEXT.Text + LOWMPTEXT.Text;

            Boolean allOK = false;

            {

                if (((HIGHMPTEXT.Text.Length > 0) && (LOWMPTEXT.Text.Length > 0)) && ((PreBox.Text.Length > 0) || (SufBox.Text.Length > 0)))

                    allOK = true;

            }

            {

                if (allOK)

                {

                    saveData();

                }

                else

                {

                    MessageBox("Missing Value, Check all text entries");

                }

                {

                    frmsplitscreen frm = new frmsplitscreen();

                    frm.info = info;

                    frm.Show();

                }

            }

        }



Answers (6)