Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7784937
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 1, 20262026-06-01T20:10:31+00:00 2026-06-01T20:10:31+00:00

With this code (listApplications is a ListView control): private void ShowApplicationPropertiesForm() { String FullPath

  • 0

With this code (listApplications is a ListView control):

    private void ShowApplicationPropertiesForm() {
        String FullPath = String.Empty; 
        String Title = String.Empty;
        String Description = String.Empty;
        Boolean Legacy = false;
        Boolean Production = false;
        Boolean Beta = false;
        MyCustomListViewItemDescendant lvi = (MyCustomListViewItemDescendant)listApplications.SelectedItems[0];
        FullPath = lvi.ExePath;
        Title = lvi.Text;
        Description = lvi.ToolTipText;

        ApplicationProperties ap = new ApplicationProperties(
            FullPath,
            Title,
            Description,
            Legacy,
            Production,
            Beta);
        ap.Show();
    }


//overloaded form constructor
public ApplicationProperties(String AFullPath, String ATitle, String ADescription, Boolean ALegacy, Boolean AProduction, Boolean ABeta) {
            this.Text = String.Format("{0} Properties", ATitle);
            textBoxFullPath.Text = AFullPath;
            textBoxTitle.Text = ATitle;
            textBoxDescription.Text = ADescription;
            checkBoxLegacy.Checked = ALegacy;
            checkBoxProduction.Checked = AProduction;
            checkBoxBeta.Checked = ABeta;
        }

…I’m getting, “System.NullReferenceException was unhandled
Message=Object reference not set to an instance of an object.”

Stepping through it, the line that bombs is:

textBoxFullPath.Text = AFullPath;

textBoxFullPath is a Textbox on a form; AFullPath has a valid value of the sort: “Q:\What\AreYou\Gonna\Do\BabyBlue.exe”

Updated:

Partially solved.

It was the old “Premature Assignment” problem. By moving the assignments from the constructor to the Load() event, it no longer bombs (code below).

HOWEVER, now nothing is displaying on the form at runtime…???!?

public partial class ApplicationProperties : Form {
        String _fullPath = String.Empty;
        String _title = String.Empty;
        String _description = String.Empty;
        Boolean legacy = false;
        Boolean production = false;
        Boolean beta = false;

        public ApplicationProperties() {
            InitializeComponent();
        }

        public ApplicationProperties(String AFullPath, String ATitle, String ADescription, Boolean ALegacy, Boolean AProduction, Boolean ABeta) {
            _fullPath = AFullPath;
            _title = ATitle;
            _description = ADescription;
            legacy = ALegacy;
            production = AProduction;
            beta = ABeta;
            this.CenterToScreen();
        }

        private void ApplicationProperties_Load(object sender, EventArgs e) {
            //this.Text = String.Format("{0} Properties", _title);          
            Text = String.Format("{0} Properties", _title);
            textBoxFullPath.Text = _fullPath;
            textBoxTitle.Text = _title;
            textBoxDescription.Text = _description;
            checkBoxLegacy.Checked = legacy;
            checkBoxProduction.Checked = production;
            checkBoxBeta.Checked = beta;
        }

Updated again:

Adding “InitializeComponent();” to the overloaded constructor did the trick – thanks, SW!

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-01T20:10:32+00:00Added an answer on June 1, 2026 at 8:10 pm

    I think the designer always calls the parameterless constructor, so I’ve gravitated to no trying to make my own constructors for WinForm Forms.

    See my suggestions to tweak below – if you don’t get to where you want, let me know and I’ll update.

        public ApplicationProperties(String AFullPath, String ATitle, String ADescription, Boolean ALegacy, Boolean AProduction, Boolean ABeta)
            : this() // --> Call the parameterless constructor before executing this code
        { 
            _fullPath = AFullPath; 
            _title = ATitle; 
            _description = ADescription; 
            legacy = ALegacy; 
            production = AProduction; 
            beta = ABeta; 
            this.CenterToScreen(); // --> Maybe move this to the Shown event (not sure if you need to)
        } 
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

This code does not compile. public class Diamond { public static void diamondOfAsterisks(String *
This code will delete the entire row if it finds an empty cell in
This code: <% string path = Request.ApplicationPath.ToString(); %> <link href=<%= path %>/Content/Site.css rel=stylesheet type=text/css
This code does not return the correct result: Pattern p=Pattern.compile(^[y]{1,4}$|^[m]{1,4}$|^[d]{1,4}$); String text1=yyyy; String text2=mmm;
This code produces a FileNotFoundException, but ultimately runs without issue: void ReadXml() { XmlSerializer
This code fails when I try to debug it using VC2010: char frd[32]=word-list.txt; FILE
This code builds without problems but fails when executed: var query = _db.STEWARDSHIP .OrderByDescending(r
This code: #include Backpack.h #include <sstream> #include <algorithm> int Backpack::getCurrentWeight() { int weight =
This code works in IDLE but not in the commandline. Why the difference? poem
this code is supposed to list recent calls with recent same nos skipped but

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.