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 6997605
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T20:18:17+00:00 2026-05-27T20:18:17+00:00

I have a data grid view and i set it datasource property as dgvEmployee.DataSource

  • 0

I have a data grid view and i set it datasource property
as

dgvEmployee.DataSource = mycollection;

i want that grid should have some property like

dgvEmployee.ShowSerialNumber = True;

Any suggestion

Thanks 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-27T20:18:17+00:00Added an answer on May 27, 2026 at 8:18 pm

    This piece of code is taken from here

        /// This class extends the the DataGridView so row numbers will 
        /// automatically appear in the row header cells. In this 
        /// implementation, the width of the column that contains the row 
        /// header cells is automatically adjusted to accomodate the row 
        /// numbering.
        /// ******************************************************************
        ///  AUTHOR: Daniel S. Soper
        ///     URL: http://www.danielsoper.com
        ///    DATE: 20 February 2007
        /// LICENSE: Public Domain. Enjoy!   :-)
        /// ******************************************************************
        /// 
        class MyDGV : DataGridView
        {
            public MyDGV()
            {
                //perform any necessary customization initialization here
            } //end default constructor
    
            protected override void OnRowPostPaint(DataGridViewRowPostPaintEventArgs e)
            { //this method overrides the DataGridView's RowPostPaint event 
              //in order to automatically draw numbers on the row header cells
              //and to automatically adjust the width of the column containing
              //the row header cells so that it can accommodate the new row
              //numbers,
    
                //store a string representation of the row number in 'strRowNumber'
                string strRowNumber = (e.RowIndex + 1).ToString();
    
                //prepend leading zeros to the string if necessary to improve
                //appearance. For example, if there are ten rows in the grid,
                //row seven will be numbered as "07" instead of "7". Similarly, if 
                //there are 100 rows in the grid, row seven will be numbered as "007".
                while (strRowNumber.Length < this.RowCount.ToString().Length) strRowNumber = "0" + strRowNumber;
    
                //determine the display size of the row number string using
                //the DataGridView's current font.
                SizeF size = e.Graphics.MeasureString(strRowNumber, this.Font);
    
                //adjust the width of the column that contains the row header cells 
                //if necessary
                if (this.RowHeadersWidth < (int)(size.Width + 20)) this.RowHeadersWidth = (int)(size.Width + 20);
    
                //this brush will be used to draw the row number string on the
                //row header cell using the system's current ControlText color
                Brush b = SystemBrushes.ControlText;
    
                //draw the row number string on the current row header cell using
                //the brush defined above and the DataGridView's default font
                e.Graphics.DrawString(strRowNumber, this.Font, b, e.RowBounds.Location.X + 15, e.RowBounds.Location.Y + ((e.RowBounds.Height - size.Height) / 2));
    
                //call the base object's OnRowPostPaint method
                base.OnRowPostPaint(e);
            } //end OnRowPostPaint method
        } //end class
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I've got some Columns in a DataGridView that have their Binding property set to
I have a Data Grid View inside a control that is displayed in a
Is it possible to have something like Data Grid or Grid View control in
i have a doubt in grid view. In Data list we have a property
Hey guys, I have an application that I want to display some data from
I have a datagridview its datasource is set to a data view -> data
I have a data table. After creating this table, I use data grid view
I have a gridview that has its DataSourceID property set to a custom ObjectDataSource
I have a set of data that has been displayed as just a simple
I have a Devexpress.XtraGrid.GridControl that I have set the DataSource to a DataTable .

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.