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();
}
}
}

VulpesRank #55 · 29.2K reputationPosted Jun 11, 2011, 9:14 AM EDT
Nigel Alford5 reputationPosted Jun 11, 2011, 9:55 AM EDT
In the trouble shooting tips I'm recommended to "use the 'new' keyword to create an object instance. or Check to determine if the object is null before calling the method"
Thanks
VulpesRank #55 · 29.2K reputationPosted Jun 11, 2011, 10:14 AM EDT
If you open up the InitializeComponent() method in the other partial class, can you see a line like this:
DIVBOX = new System.Windows.Forms.ComboBox();
Guest UserRank #1,422 · 1.2K reputationPosted Jun 11, 2011, 2:17 PM EDT
.
.
VulpesRank #55 · 29.2K reputationPosted Jun 12, 2011, 4:25 AM EDT
Must have been half-asleep when I made that post!
Nigel Alford5 reputationPosted Jun 13, 2011, 6:22 AM EDT
DIVBOX.SelectedText.ToString();
Gotta love it