A community member has associated this post with a similar question:
Datagridview Formatting issue on loading

Only moderators can edit this content.

Datagridview Formatting issue on loading

rahul kumar 605 Reputation points
2023-07-04T08:10:05.5433333+00:00

I have used the following code on my customdatagridview , but found out that it is not working properly

  public partial class Paymentdatagridview : DataGridView
    {
              

    public Paymentdatagridview()
    {

        
        // i have set enableheadervisualstyles to false 
        // make bold the headers
        // Add the columns to your custom DataGridView
        DataGridViewColumn column1 = new DataGridViewTextBoxColumn();
        column1.Name = "Column1";
        column1.HeaderText = "Particulars";
        column1.AutoSizeMode = DataGridViewAutoSizeColumnMode.AllCells;
        column1.SortMode = DataGridViewColumnSortMode.Automatic;
        this.Columns.Add(column1);
        DataGridViewColumn column2 = new DataGridViewTextBoxColumn();
        column2.Name = "Column2";
        column2.HeaderText = "Amount";
        column2.AutoSizeMode = DataGridViewAutoSizeColumnMode.Fill;
        column2.SortMode = DataGridViewColumnSortMode.Programmatic;
        this.Columns.Add(column2);
        this.AllowUserToAddRows = true;
        this.RowHeadersVisible = false;
        this.ColumnHeadersDefaultCellStyle.Font = new Font("Tahoma", 9.75F, FontStyle.Bold);
        this.CellBorderStyle = DataGridViewCellBorderStyle.None;        
        InitializeComponent();
    }

enter image description here

Above is the image when it is loaded , you can see that first row's color is different although i had tried to set the background color of the datagridview to change according to its parent by using following code
second problem is when i starts editing in it , this white colour eats up the following upcoming rows
User's image

another issue is I am trying to set the font to be bold for each cells but it is also not working for 1st row .
User's image

Developer technologies Windows Forms
Developer technologies .NET Other
Developer technologies C#
{count} votes