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

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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 14, 20262026-05-14T14:08:23+00:00 2026-05-14T14:08:23+00:00

is it possible to paint line every empty line in DataGridView ? ex: 123

  • 0

is it possible to paint line every empty line in DataGridView ?

ex:

123 | 444 | 555    
123 | 555 | 666

333 | 555 | 666

666 | 777 | 888

it will be:

123 | 444 | 555    
123 | 555 | 666
---------------    
333 | 555 | 666
---------------    
666 | 777 | 888

in WinForm – C#

thank’s in advance

  • 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-14T14:08:23+00:00Added an answer on May 14, 2026 at 2:08 pm

    Pretty close to what you need. The row will be empty in your case. You can do some more optimizations with color, font etc.

    alt text http://img72.imageshack.us/img72/6450/76236843.jpg

        private void dataGridView1_RowPostPaint(object sender, DataGridViewRowPostPaintEventArgs e)
        {
            if (e.RowIndex == 2)
            {
                // Calculate the bounds of the row 
                int rowHeaderWidth = dataGridView1.RowHeadersVisible ?
                                     dataGridView1.RowHeadersWidth : 0;
                Rectangle rowBounds = new Rectangle(
                    rowHeaderWidth,
                    e.RowBounds.Top,
                    dataGridView1.Columns.GetColumnsWidth(
                            DataGridViewElementStates.Visible) -
                            dataGridView1.HorizontalScrollingOffset + 1,
                   e.RowBounds.Height);
    
                // Paint the row
                ControlPaint.DrawStringDisabled(e.Graphics, "- - - - - - - - - - - - - - - - - - - - - - - -", new Font("Times New Roman", 15f), Color.DarkGray, rowBounds, TextFormatFlags.Default);
            }
        }
    

    Form2_Load() – Just to make the code complete so that you can just copy paste to reproduce.

    private void Form2_Load(object sender, EventArgs e)
            {
                this.dataGridView1.ColumnCount = 4;
                this.dataGridView1.Columns[0].Name = "Recipe";
                this.dataGridView1.Columns[0].SortMode =
                    DataGridViewColumnSortMode.NotSortable;
                this.dataGridView1.Columns[1].Name = "Category";
                this.dataGridView1.Columns[2].Name = "Main Ingredients";
                this.dataGridView1.Columns[3].Name = "Rating";
    
                // Hide the column that contains the content that spans 
                // multiple columns.
                this.dataGridView1.Columns[2].Visible = false;
    
                // Populate the rows of the DataGridView.
                string[] row1 = new string[]{"Meatloaf", "Main Dish",
                "1 lb. lean ground beef, 1/2 cup bread crumbs, " + 
                "1/4 cup ketchup, 1/3 tsp onion powder, 1 clove of garlic, " +
                "1/2 pack onion soup mix, dash of your favorite BBQ Sauce",
                "****"};
                string[] row2 = new string[]{"Key Lime Pie", "Dessert", 
                "lime juice, whipped cream, eggs, evaporated milk", "****"};
                string[] row3 = new string[]{"Orange-Salsa Pork Chops", 
                "Main Dish", "pork chops, salsa, orange juice, pineapple", "****"};
                string[] row4 = new string[]{"Black Bean and Rice Salad", 
                "Salad", "black beans, brown rice", "****"};
                string[] row5 = new string[]{"Chocolate Cheesecake", 
                "Dessert", "cream cheese, unsweetened chocolate", "***"};
                string[] row6 = new string[]{"Black Bean Dip", "Appetizer",
                "black beans, sour cream, salsa, chips", "***"};
                object[] rows = new object[] { row1, row2, row3, row4, row5, row6 };
                foreach (string[] rowArray in rows)
                {
                    this.dataGridView1.Rows.Add(rowArray);
                }
            }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

No related questions found

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.