troubleshooting Question

Creating a DataGridView by coding

Avatar of Rama Tito
Rama TitoFlag for Malaysia asked on
1 Comment1 Solution280 ViewsLast Modified:

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()

        /// <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();
            // 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";

        /// <summary>
        /// The main entry point for the application.
        /// </summary>
        static void Main()

Join our community to see this answer!
Unlock 1 Answer and 1 Comment.
Start Free Trial
Learn from the best

Network and collaborate with thousands of CTOs, CISOs, and IT Pros rooting for you and your success.

Andrew Hancock - VMware vExpert
See if this solution works for you by signing up for a 7 day free trial.
Unlock 1 Answer and 1 Comment.
Try for 7 days

”The time we save is the biggest benefit of E-E to our team. What could take multiple guys 2 hours or more each to find is accessed in around 15 minutes on Experts Exchange.

-Mike Kapnisakis, Warner Bros