Click here to Skip to main content
15,884,628 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hello All :)
I Need Help
I have a problem when running a MainForm (1) from login(2) form ( With Button show MainForm ) I have a show More error because The Class SeleniumControl.cs Call MainForm (1) by : Program.MainForm.btnLogin ..... Or Other

Program = startup object

My class Program Code
C#
using System;
using System.Collections.Generic;
using System.Linq;
using System.Windows.Forms;
using System.Threading;
using System.Data;
using System.Drawing;
using System.Text;


namespace MyTools
{
    static class Program
    {
        public static democs democs;
        public static MainForm MainForm;
        public static LoadingForm loadingForm;
        public static gpaly gpaly;
            /// <summary>
        /// The main entry point for the application.
        /// </summary>
        [STAThread]
        static void Main()
        {
                           
            Application.EnableVisualStyles();
            Application.SetCompatibleTextRenderingDefault(false);
           // MainForm = new MainForm();
            login= new login();

         //Application.Run(MainForm);
          //democs = MainForm.sendOver();

            login= new login();
            Application.Run(login);
                     
        }
    }
}


Login Code


C#
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;

namespace MYTools
{
    public partial class login: Form

    {
           public login()
        {
             InitializeComponent();
        this.IsMdiContainer = true; // This will allow the Form #0 to be responsive while other forms are opened.
        }


        private void button1_Click(object sender, EventArgs e)
        {
         
            //MainForm = new MainForm();
          //Application.Run(new MainForm());
            
           

           // Program.MainForm();
         //   var yourObject = new SeleniumControl();
           // yourObject.MainForm();

           // MainForm = new MainForm();
          //  Application.Run(MainForm);
                        
          }

        }

    }



short! when you open the form(1) from login form before him Gets problem I, for example, I need to work Button When Click The Button open MainForm With The Class SeleniumControl.cs ! Or Any Help !

When using

C#
Form = new Form();


in
In Program.cs
The project works successfully, but shows,Problems or problems in different example of what line In My class

C#
if (Program.form.dgGroups.RowCount == 0) await getGrps();


Object reference not set to an instance of an object.
Error : {MYTools.SeleniumControl} .......

did not sleep and I feel very tired because of this problem
Please Help Me
Thanks All

But I've Capture desktop video until the problem appear clearly and I hope you can watch the video and find a solution if possible
And apologized for any inconvenience


https://www.youtube.com/watch?v=683o_xwQ-H4&feature=youtu.be[^]
Posted
Comments
Afzaal Ahmad Zeeshan 30-Oct-15 17:02pm    
You cannot solve the "NullReferenceException"? Just Google for, "how to initialize a variable in C#" and you will get the answer. :-)

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900