Link to home
Start Free TrialLog in
Avatar of Rama Tito
Rama TitoFlag for Malaysia

asked on

Creating a DataGridView by coding

Hi,

I am trying to create a empty datagridview by coding. When i am trying to execute, no error and no form. Its just switch from program mode to run mode and back to program mode by itself.
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 GridSetting
{
    public partial class MainGrid : System.Windows.Forms.Form
    {
        private System.Windows.Forms.DataGridView dataGridViewBase;
        private System.Windows.Forms.DataGridViewTextBoxColumn dataGridTextBoxColumn2;
        private System.Windows.Forms.DataGridViewTextBoxColumn dataGridTextBoxColumn3;
        private System.Windows.Forms.DataGridViewTextBoxColumn dataGridTextBoxColumn4;
        private System.Windows.Forms.DataGridViewTextBoxColumn dataGridTextBoxColumn5;

        public MainGrid()
        {
            InitializeComponent();
        }

        /// <summary>
		/// Clean up any resources being used.
		/// </summary>
		

		#region Windows Form Designer generated code
		/// <summary>
		/// Required method for Designer support - do not modify
		/// the contents of this method with the code editor.
		/// </summary>
        private void InitializeComponent()
        {
            this.dataGridViewBase = new System.Windows.Forms.DataGridView();
            this.dataGridTextBoxColumn2 = new System.Windows.Forms.DataGridViewTextBoxColumn();
            this.dataGridTextBoxColumn3 = new System.Windows.Forms.DataGridViewTextBoxColumn();
            this.dataGridTextBoxColumn4 = new System.Windows.Forms.DataGridViewTextBoxColumn();
            this.dataGridTextBoxColumn5 = new System.Windows.Forms.DataGridViewTextBoxColumn();
            ((System.ComponentModel.ISupportInitialize)(this.dataGridViewBase)).BeginInit();
            
            // 
            // dataGridViewBase
            // 
            this.dataGridViewBase.Location = new System.Drawing.Point(0, 0);
            this.dataGridViewBase.Name = "dataGridViewBase";
            this.dataGridViewBase.Size = new System.Drawing.Size(240, 150);
            this.dataGridViewBase.TabIndex = 0;
            
            // 
            // dataGridTextBoxColumn2
            // 
            this.dataGridTextBoxColumn2.Name = "dataGridTextBoxColumn2";
            // 
            // dataGridTextBoxColumn3
            // 
            this.dataGridTextBoxColumn3.Name = "dataGridTextBoxColumn3";
            // 
            // dataGridTextBoxColumn4
            // 
            this.dataGridTextBoxColumn4.Name = "dataGridTextBoxColumn4";
            // 
            // dataGridTextBoxColumn5
            // 
            this.dataGridTextBoxColumn5.Name = "dataGridTextBoxColumn5";
            // 
            // MainGrid
            // 
            this.ClientSize = new System.Drawing.Size(292, 266);
            this.Name = "MainGrid";
            ((System.ComponentModel.ISupportInitialize)(this.dataGridViewBase)).EndInit();
            this.ResumeLayout(false);

        }
        #endregion
        /// <summary>
        /// The main entry point for the application.
        /// </summary>
        [STAThread]
        static void Main()
        {
            Application.EnableVisualStyles();
            Application.DoEvents();
            
        }





    }
}

Open in new window

ASKER CERTIFIED SOLUTION
Avatar of Bob Learned
Bob Learned
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial