none
message The variable 'row' is either undeclared or was never assigned._

    Question

  • hello my freinds this is my designer.cs code that i was declared row variable but vStudio shows error
    this.dgv_Customers.AllowUserToAddRows = false;
                this.dgv_Customers.AllowUserToDeleteRows = false;
                this.dgv_Customers.ColumnHeadersHeightSizeMode = System.Windows.Forms.DataGridViewColumnHeadersHeightSizeMode.AutoSize;
                this.dgv_Customers.Columns.AddRange(new System.Windows.Forms.DataGridViewColumn[] {
                this.CustomerID,
                this.DateCreated,
                this.c_fullname,
                this.mob,
                this.address,
                this.cShowInvoice});
                dataGridViewCellStyle2.Alignment = System.Windows.Forms.DataGridViewContentAlignment.MiddleLeft;
                dataGridViewCellStyle2.BackColor = System.Drawing.SystemColors.Window;
                dataGridViewCellStyle2.Font = new System.Drawing.Font("Mj_AridiNaskh Bold", 10F);
                dataGridViewCellStyle2.ForeColor = System.Drawing.Color.FromArgb(((int)(((byte)(128)))), ((int)(((byte)(64)))), ((int)(((byte)(0)))));
                dataGridViewCellStyle2.SelectionBackColor = System.Drawing.SystemColors.Highlight;
                dataGridViewCellStyle2.SelectionForeColor = System.Drawing.SystemColors.HighlightText;
                dataGridViewCellStyle2.WrapMode = System.Windows.Forms.DataGridViewTriState.False;
                this.dgv_Customers.DefaultCellStyle = dataGridViewCellStyle2;
                this.dgv_Customers.Location = new System.Drawing.Point(24, 337);
                this.dgv_Customers.Name = "dgv_Customers";
                System.Windows.Forms.DataGridViewRow row = this.dgv_Customers.RowTemplate;
                row.Height = 35;
                this.dgv_Customers.ReadOnly = true;
                this.dgv_Customers.RightToLeft = System.Windows.Forms.RightToLeft.Yes;
                this.dgv_Customers.Size = new System.Drawing.Size(637, 213);
                this.dgv_Customers.TabIndex = 2;
                this.dgv_Customers.CellContentClick += new System.Windows.Forms.DataGridViewCellEventHandler(this.dataGridView1_CellContentClick);
    tnx pls help
    Monday, April 10, 2017 6:11 PM

Answers

  • Hello,

    Set a break point on the first line of code then step through the code line by line, which line is causing the exception?


    Please remember to mark the replies as answers if they help and unmark them if they provide no help, this will help others who are looking for solutions to the same or similar problem. Contact via my Twitter (Karen Payne) or Facebook (Karen Payne) via my MSDN profile but will not answer coding question on either.
    VB Forums - moderator
    profile for Karen Payne on Stack Exchange, a network of free, community-driven Q&A sites

    Monday, April 10, 2017 6:15 PM
    Moderator
  • First, clean and rebuild.  Also make sure you are targeting the right platform.

    And @Karen, I assume this happens in the designer, so it's likely impractical to debug with breakpoints.


    Yep I read over the part being designer code

    Please remember to mark the replies as answers if they help and unmark them if they provide no help, this will help others who are looking for solutions to the same or similar problem. Contact via my Twitter (Karen Payne) or Facebook (Karen Payne) via my MSDN profile but will not answer coding question on either.
    VB Forums - moderator
    profile for Karen Payne on Stack Exchange, a network of free, community-driven Q&A sites

    Monday, April 10, 2017 6:59 PM
    Moderator
  • Make sure the columns, defaultCellStyle and the CellContentClick event you defined are intact. Feels like the case of winform corruption. 

    Entering the exact exception you face can help in diagnosing it more.

    Looks like from the title of query '

    The variable 'row' is either undeclared or was never assigned.' 

    error is around following line. 

     System.Windows.Forms.DataGridViewRow row = this.dgv_Customers.RowTemplate;

    Can you try removing the line? 


    Mark Answered, if it solves your question and Vote if you found it helpful.
    Rohit Arora

    Tuesday, April 11, 2017 4:26 AM

All replies

  • Hello,

    Set a break point on the first line of code then step through the code line by line, which line is causing the exception?


    Please remember to mark the replies as answers if they help and unmark them if they provide no help, this will help others who are looking for solutions to the same or similar problem. Contact via my Twitter (Karen Payne) or Facebook (Karen Payne) via my MSDN profile but will not answer coding question on either.
    VB Forums - moderator
    profile for Karen Payne on Stack Exchange, a network of free, community-driven Q&A sites

    Monday, April 10, 2017 6:15 PM
    Moderator
  • First, clean and rebuild.  Also make sure you are targeting the right platform.

    And @Karen, I assume this happens in the designer, so it's likely impractical to debug with breakpoints.

    Monday, April 10, 2017 6:35 PM
  • First, clean and rebuild.  Also make sure you are targeting the right platform.

    And @Karen, I assume this happens in the designer, so it's likely impractical to debug with breakpoints.


    Yep I read over the part being designer code

    Please remember to mark the replies as answers if they help and unmark them if they provide no help, this will help others who are looking for solutions to the same or similar problem. Contact via my Twitter (Karen Payne) or Facebook (Karen Payne) via my MSDN profile but will not answer coding question on either.
    VB Forums - moderator
    profile for Karen Payne on Stack Exchange, a network of free, community-driven Q&A sites

    Monday, April 10, 2017 6:59 PM
    Moderator
  • Make sure the columns, defaultCellStyle and the CellContentClick event you defined are intact. Feels like the case of winform corruption. 

    Entering the exact exception you face can help in diagnosing it more.

    Looks like from the title of query '

    The variable 'row' is either undeclared or was never assigned.' 

    error is around following line. 

     System.Windows.Forms.DataGridViewRow row = this.dgv_Customers.RowTemplate;

    Can you try removing the line? 


    Mark Answered, if it solves your question and Vote if you found it helpful.
    Rohit Arora

    Tuesday, April 11, 2017 4:26 AM