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();
}
}
}
Nigel AlfordPosted Jun 13, 2011, 10:22 AM
DIVBOX.SelectedText.ToString();
Gotta love it
VulpesPosted Jun 12, 2011, 8:25 AM
Must have been half-asleep when I made that post!
Guest UserPosted Jun 11, 2011, 6:17 PM
.
.
VulpesPosted Jun 11, 2011, 2:14 PM
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();
Nigel AlfordPosted Jun 11, 2011, 1:55 PM
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
VulpesPosted Jun 11, 2011, 1:14 PM