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

  • Home
  • SEARCH
  • 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 6832165
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T22:49:32+00:00 2026-05-26T22:49:32+00:00

I have 2 forms connected to a database, LoadDocument form and a Fom1 that

  • 0

I have 2 forms connected to a database, LoadDocument form and a Fom1 that is the primary form. In LoadDocument I get document names out of my database, and when I close LoadDocument I send the document id to Form1 so I can retrieve its content there.

The only problem is that if i make a function in Form1, called public void showContent() my LoadDocument can’t call it because it’s not static, and if I make it static, I get problems creating radioButtons.

public partial class Form1 : Form
{
    public void showTasks()
    {
        radioButtons = new RadioButton[numberOfTasks];
        for (int i = 0; i < numberOfTasks; ++i)
        {
            radioButtons[i] = new RadioButton();
            radioButtons[i].Text = "Task " + (i+1);
            radioButtons[i].Location = new System.Drawing.Point(
                10, 10 + i * 20);
            groupBox1.Controls.Add(radioButtons[i]);
            radioButtons[i].Click += new EventHandler(this.radioButtons_Click);
        }
    }
}

Is there any way I can call this function from LoadDocument without making it static? Do I have to make LoadDocument dynamic, and in that case how?

EDIT: I guess this piece of code would be quite relevant:

    private LoadDocument m_form1;
    private bool m_underConstruction = false;
    private void ShowLoadDocument()
    {
        if (m_underConstruction)
        {
            // We're about to show it anyway
            return;
        }
        m_underConstruction = true;
        try
        {
            if (m_form1 == null)
            {
                m_form1 = new LoadDocument();
                // m_form1.FormClosed += new FormClosedEventHandler(m_form1_FormClosed);
                m_form1.Show();
            }
        }
        finally
        {
            m_underConstruction = false;
        }
        m_form1.BringToFront();
        m_form1.Activate();
    }
  • 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-05-26T22:49:32+00:00Added an answer on May 26, 2026 at 10:49 pm

    I’m not sure about the control flow and the co-existence of the two forms, but you could pass the instance of Form1 to LoadDocument and call the method directly on that object. Like:

    public class LoadDocument : Form {
    
        private Form1 form1;
        public LoadDocument(Form1 form1) {
            this.form1 = form1;
        }
    
        // later
    
        public void Method() {
            form1.showTasks();
        }
    }
    
    
    public class Form1 : Form {
    
         public void SomeMethod() {              
            LoadDocument doc = new LoadDocument(this);
            doc.Show();
         }
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a registration form that is connected to a database table that uses
I have an input form connected to a database. After [the form is submitted],
I have the following code that returns rows from a database when a form
I have written an application that is connected to SQL database in C#.There are
i have a Form database with connected to php coding. the problem is when
I have a simple form that I use to list the names of all
I have an access database that uses a continuous subform on a form. The
I currently have a PHP form that uses AJAX to connect to MySQL and
i have a PHP contact form that submits data, and an email...: <?php $dbh=mysql_connect
I have forms in my page a get and a post and i want

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.