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 7895987
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 3, 20262026-06-03T07:46:39+00:00 2026-06-03T07:46:39+00:00

I am using Form2 to update the default printer and send the string to

  • 0

I am using Form2 to update the default printer and send the string to Form3. I typically have no problem operating from Form1 and passing data to Form2 or Form3. But having trouble using Form2 to update Form3!

The real names are: Form1 = Form1, Form2 = formUserSettings, Form3 = formViewDwg

Here is the code in Form1, calling Form2 (formUserSettings):

private void configureStartupSettingsToolStripMenuItem_Click(object sender, EventArgs e)
    {
        formUserSettings frmUsr = new formUserSettings(prnNameString, prnDriverString, prnPortString,
            Settings.Default.DefaultPrinter.ToString(), Settings.Default.ViewStyle, Settings.Default.ReCenterEVafterDwgClose, 
            Settings.Default.SyncListDwgNum, listMain);
        frmUsr.ValueUpdated += new ValueUpdatedEventHandler(frmUsr_ValueUpdated); //---added 3-22-12
        //frmUsr.ValueUpdated2 += new ValueUpdatedEventHandler(newPrn_ValueUpdated); //---added 4-12-12

        frmUsr.ShowDialog();
        frmUsr.Close();
    }

Here’s the code inside Form2 (formUserSettings) that tries to send the printer name to Form3 (formViewDwg).

if (Application.OpenForms.OfType<formViewDwg>().Count() > 0)
            {
                newEntry = comboPrinters.Items[index].ToString();
                formViewDwg frmVd = this.Owner as formViewDwg;
                delPassData del = new delPassData(frmVD.passedNewVal);
                del(newEntry);
            }
            else
            {
                frmVD = new formViewDwg(EViewMethods.currentPartPath, EViewMethods.currentPartNum, EViewMethods.currentDwgNum,
                    Settings.Default.DefaultPrinter, Settings.Default.DefaultPrinterDriver, Settings.Default.DefaultPrinterPort,
                    EViewMethods.defaultPrn[0], EViewMethods.defaultPrn[1], EViewMethods.defaultPrn[2], lBox, false, false);

                newEntry = comboPrinters.Items[index].ToString();
                delPassData del = new delPassData(frmVD.passedNewVal);
                del(newEntry);
            }

Inside Form3 (formViewDwg) is:

public void passedNewVal(string newPrn) // using the delegate "delPassData" declared in formUserSettings
    {
        try
        {
            comboPrinter.Text = newPrn;
        }
        catch
        {

        }
    }

The error is “Delegate to an instance method cannot have null ‘this'”.

  • 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-03T07:46:40+00:00Added an answer on June 3, 2026 at 7:46 am

    Well I never found out how to send the string from Form2 to Form3, but I found a good solution: When Form2 closes and sends its string to Form1 from “frmUsr_ValueUpdated”, it checks to see if Form3 is open. If it is then a public method within Form3 is used to update its comboBox.text as follows. (Form1 = Form1, Form2 = formUserSettings, Form3 = formViewDwg {instance = frmVD})

    private void frmUsr_ValueUpdated(object sender, ValueUpdatedEventArgs e) //---added 3-22-12
        {
            // Update the printer name on Form1 with the new value from formUserSettings
            string prnStr = e.NewValue;
            string[] parts = prnStr.Split('^'); //the printer name, driver and port were passed by e.NewValue, being separated by a "^"
    
            //---added 5-7-12
            EViewMethods.defaultPrn[0] = parts[0]; //printer name
            EViewMethods.defaultPrn[1] = parts[1]; //printer driver
            EViewMethods.defaultPrn[2] = parts[2]; //printer port
    
            toolStripStatusLabel3.Text = parts[0];
    
            //---added 5-7-12
            if (frmVD != null && !frmVD.IsDisposed) //want to send the new printer name now if formViewDwg is already open. If it is not open, then when it is called to open, the formViewDwg constructor will pass the new printer to it.
            {
                frmVD.ProcessPrinterName(parts[0]); //ProcessPrinterName is a public method inside formViewDwg.  Can call here because formViewDwg is already open!
            }
        }
    

    Inside formViewDwg (Form3) is the public ProcessPrinterName method:

    public void ProcessPrinterName(string message)
        {
            comboPrinter.Text = message;
        }
    

    If Form3 (formViewDwg) is not open then the updated printer name will be passed to it whenever an instance is invoked through its constructor parameter list. Printer name will be passed as “string prnName” in the constructor:

    public formViewDwg(string currentPath, string currentPartNum, string currentDwgNum,
                string prnNameList, string prnDriverList, string prnPortList,
                string prnName, string prnDriver, string prnPort, ListBox lstBox, bool usingEngCode, bool engCodeIsEnabled) //---added 3-12-12
        {
            InitializeComponent();
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm using Symfony2 Framework, and I want to update an entity with data from
I have an object that I am trying to update using MVC(2), also using
In a ajax-driven site I have added some default data using the ajaxSetup, ala
I have a field in my update form called approve which is using the
I am using Delphi XE2 with update 4 hotfix 1 My default FMX app
I am using Ajax to receive a JSON update: $(document).ready(function(){ $('form').submit(function(event){ event.preventDefault(); var form
I have a website that's using forms authentication and membership. A user must have
I have a web app using forms authentication and I have restricted a folder
I'm having a weird problem with a threaded class using Boost::threads. Here is a
I have a VBA program to download attachments from a Mail Item. I launch

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.