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

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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 12, 20262026-05-12T13:33:11+00:00 2026-05-12T13:33:11+00:00

Late Edit I tagged this as a C# question as well as C++ because

  • 0

Late Edit I tagged this as a C# question as well as C++ because the problem presents itself in both languages, and solution if shown would most likely be in the C# (the majority of the market).

I have been developing an application under .net 2.0 (C++ to be specific, but irrelevant).

This application uses a custom derived datagridview. This datagridview will occasionally have sever artifacting issues regarding the region of the DGV that does not contain cells, as well as the scrollbar. During some resizing actions, a black rectangle will draw in the bottom portion of the datagridview, which will in effect limit the size of the grid. The scrollbar also gets shrunk to fit inside the nonbugged region. It seems to me as the system believes the DGV is the wrong size, and is drawing into the wrong region.

alt text http://img12.imageshack.us/img12/2213/81356991.jpg

There are only two ways I can find to fix the symptoms:
1. Clicking a column to resize will automatically fix the grid
2. Calling the AutoResizeRows() function in the DGV will do the fix (but I believe is something that is called from point 1).

Some of the modifications to the Custom DGV:
1) Configured to handle drag\drop of multiple rows.
2) Point 1 required OnCellPainting to be overridden to draw drag lines. Function can be posted if it seems symptomatic.
3) The problems always happen on a resize (both manual and automatic can cause the problem), but there is no custom code in the resize event.

late edit code for onCellPainting. Other functions overridden in the gridview: OnMouseDown, OnCellMouseDown, OnClick, OnMouseMove, OnDragOver, OnDragDrop, OnDragLeave, OnKeyDown, None of which seem symptomatic

   protected: [DebuggerStepThrough()]
   virtual System::Void OnCellPainting(DataGridViewCellPaintingEventArgs ^e) override 
   {
      //draws red drag/drop target indicator lines if necessary
      if (this->AllowDrop && _DragDropCurrentIndex > -1 && ShowDragLines)
      {
         System::Drawing::Pen ^p = gcnew Pen(System::Drawing::Color::Navy, 3);

         //row drag/drop
         if (e->RowIndex == _DragDropCurrentIndex && 
             _DragDropCurrentIndex <= this->RowCount)
         {
            //if this cell is in the same row as the mouse cursor
            e->Graphics->DrawLine(
               p, 
               e->CellBounds.Left, 
               e->CellBounds.Top - 1, 
               e->CellBounds.Right, 
               e->CellBounds.Top - 1);
         } //end if

         if(e->RowIndex == this->Rows->Count - 1 && 
            _DragDropCurrentIndex == Int32::MaxValue)
         {
            e->Graphics->DrawLine(
               p, 
               e->CellBounds.Left, 
               e->CellBounds.Bottom + 1, 
               e->CellBounds.Right, 
               e->CellBounds.Bottom + 1);            
         }
      } //end if
      DataGridView::OnCellPainting(e);
   } //end OnCellPainting

*More Edits
None of these work to rid the problem, the only thing that fixes it AFTER the problem happens is AutoResizeRows(AllCells)// Only AllCells fixes it. It’s very slow and undesirable.

Refresh();
UpdateBounds();
Update();
Invalidate();
PerformLayout();
ResetBackColor();
ResetBindings();
ResetForeColor();
ResetText();
UpdateStyles();

  • 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-12T13:33:11+00:00Added an answer on May 12, 2026 at 1:33 pm

    It sounds to me like your control isn’t rendering its layout properly.
    Did you suspend layout at some point in your code, and then never resumelayout?

    Doing so will allow your control to function properly, but not lay out all of its components properly.

    • 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.