locked
form datagrid view does't display properly RRS feed

  • Question

  • When i starts application & opens child form first time, all datadridviews display properly but when i reopen same form it looks like this.

    used double buffer , form refresh, dgv refresh, do events but nothing works.

    Tuesday, October 11, 2016 11:30 AM

Answers

  • In my case, as an example, I create a new project, add aDGV via designer, in code add some data rows to DGV and run.

    Most times I get the OP effects. I also can't figure out why it sometimes doesn't show those effects and runs normally. The bizarre effects change when clicking on the DGV after run, sometimes completing the 'fill' of the DGV and sometimes just further partial 'fill' of the DGV - nothing is exactly repeatable.


    Regards Les, Livingston, Scotland

     I get the same unpredictable behavior and it seems to only redraw itself correctly after i click on the Dgv in the running application or do something to make the Dgv repaint itself again.

     Here i created a new form project,  added a DGV with 3 TextBoxColumns added to it,  then used the code below in the Form Load event.  As you can see in the Gif below,  it does not draw the Rows until i click on the DGV with the mouse or do something to make the Dgv repaint itself.

    Public Class Form1
        Private Sub Form1_Load(sender As Object, e As EventArgs) Handles MyBase.Load
            For i As Integer = 0 To 20
                DataGridView1.Rows.Add(New String() {"A" & i.ToString, "B" & i.ToString, "C" & i.ToString})
            Next
        End Sub
    End Class



    If you say it can`t be done then i`ll try it

    • Edited by IronRazerz Tuesday, October 11, 2016 7:10 PM
    • Proposed as answer by Neda Zhang Wednesday, October 12, 2016 4:51 AM
    • Marked as answer by Neda Zhang Tuesday, October 18, 2016 1:57 AM
    Tuesday, October 11, 2016 6:16 PM

All replies

  • Hi

    Can't really help, but just to say I have the exact same issue. Had it since last major Win 10 update (don't really know if related to update though).

    Seems that it doesn't always show those issues, but most times it does. When running, just clicking on the DGV seems to 'fill' in the missing cells.


    Regards Les, Livingston, Scotland

    Tuesday, October 11, 2016 11:40 AM
  •  I am running Win7 and i have noticed pretty much the same type of problem with DataGridView controls.  On my end,  this happens when the app is first ran.  It did not do this when i was using VS2010 and .Net framework 4.0.  After upgrading to VS2015 Community and installing .Net framework 4.5 or 4.6 is when i noticed this happening.  Perhaps this should be reported to MS.

    If you say it can`t be done then i`ll try it

    • Edited by IronRazerz Tuesday, October 11, 2016 2:49 PM
    Tuesday, October 11, 2016 2:47 PM
  • Hello,

    Generally speaking if it worked the first time and not afterwards I have to ask, are you creating the form as follows

    Dim f As New YourFormName

    Each time you want to display the child form? If not this can be a source of why the DataGridView is not showing correctly.


    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

    Tuesday, October 11, 2016 3:30 PM
  • Hello,

    Generally speaking if it worked the first time and not afterwards I have to ask, are you creating the form as follows

    Dim f As New YourFormName

    Each time you want to display the child form? If not this can be a source of why the DataGridView is not showing correctly.


    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

    Hi

    In my case, as an example, I create a new project, add aDGV via designer, in code add some data rows to DGV and run.

    Most times I get the OP effects. I also can't figure out why it sometimes doesn't show those effects and runs normally. The bizarre effects change when clicking on the DGV after run, sometimes completing the 'fill' of the DGV and sometimes just further partial 'fill' of the DGV - nothing is exactly repeatable.


    Regards Les, Livingston, Scotland

    Tuesday, October 11, 2016 4:10 PM
  • Interesting, never had this happen to me before and have done various loads of data with and without formatting.


    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

    Tuesday, October 11, 2016 6:00 PM
  • In my case, as an example, I create a new project, add aDGV via designer, in code add some data rows to DGV and run.

    Most times I get the OP effects. I also can't figure out why it sometimes doesn't show those effects and runs normally. The bizarre effects change when clicking on the DGV after run, sometimes completing the 'fill' of the DGV and sometimes just further partial 'fill' of the DGV - nothing is exactly repeatable.


    Regards Les, Livingston, Scotland

     I get the same unpredictable behavior and it seems to only redraw itself correctly after i click on the Dgv in the running application or do something to make the Dgv repaint itself again.

     Here i created a new form project,  added a DGV with 3 TextBoxColumns added to it,  then used the code below in the Form Load event.  As you can see in the Gif below,  it does not draw the Rows until i click on the DGV with the mouse or do something to make the Dgv repaint itself.

    Public Class Form1
        Private Sub Form1_Load(sender As Object, e As EventArgs) Handles MyBase.Load
            For i As Integer = 0 To 20
                DataGridView1.Rows.Add(New String() {"A" & i.ToString, "B" & i.ToString, "C" & i.ToString})
            Next
        End Sub
    End Class



    If you say it can`t be done then i`ll try it

    • Edited by IronRazerz Tuesday, October 11, 2016 7:10 PM
    • Proposed as answer by Neda Zhang Wednesday, October 12, 2016 4:51 AM
    • Marked as answer by Neda Zhang Tuesday, October 18, 2016 1:57 AM
    Tuesday, October 11, 2016 6:16 PM
  • The question I would ask about loading data row by row is, what happens when there is a large amount of data? What happens if this is a DataTable or other data source, sure the same logic can be used but this should not have to be.

    Generally speaking an issue such as this one is not normal in respect to load first time is good then any calls thereafter don't.  The only time I've seen this behavior is when data has changed and falls out of bounds of say cell formatting and has a try-catch that is swallowing an exception in that event or the DataGridView Data error event e.g. e.Cancel = true etc.

    So with that I would ask if the code in this form is not large to show it here and how the form is being called can assist in figuring this out 


    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

    Wednesday, October 12, 2016 9:48 AM