DataGridView "not always"/sometimes adjusting row height for wordwrap
-
I have a datagridview bound to a bindingsource bound to a List<>. The datagridview is sitting on a tabpage; the bindingsource is bound to the List<> while the tabpage is not current. Then, when the tabpage is made current, i.e., is made visible, the text that overflows a single line in the datagridview is wrapped but the rowheight is not adjusted for the second and subsequent lines of text. On the other hand, if the bindingsource is bound while the datagridview is visible, the rowheight is set correctly. I realize I can wait till the tabpage is current/visible to bind the bindingsource, but it just doesn't seem that should be required. Thanks in advance.
Snerril Blackmon
-
I have a datagridview bound to a bindingsource bound to a List<>. The datagridview is sitting on a tabpage; the bindingsource is bound to the List<> while the tabpage is not current. Then, when the tabpage is made current, i.e., is made visible, the text that overflows a single line in the datagridview is wrapped but the rowheight is not adjusted for the second and subsequent lines of text. On the other hand, if the bindingsource is bound while the datagridview is visible, the rowheight is set correctly. I realize I can wait till the tabpage is current/visible to bind the bindingsource, but it just doesn't seem that should be required. Thanks in advance.
Snerril Blackmon
You could try using the
BindingSource.ResetBindings()
when the DGV becomes visible. This will cause it to reset its data and display.Henry Minute Do not read medical books! You could die of a misprint. - Mark Twain Girl: (staring) "Why do you need an icy cucumber?" “I want to report a fraud. The government is lying to us all.”
-
You could try using the
BindingSource.ResetBindings()
when the DGV becomes visible. This will cause it to reset its data and display.Henry Minute Do not read medical books! You could die of a misprint. - Mark Twain Girl: (staring) "Why do you need an icy cucumber?" “I want to report a fraud. The government is lying to us all.”
Henry, Charming solution. I had tried the BindingSource.ResetBindings()in several events but (silly me) I had never put it in the VisibleChanged event. I appreciate you. Sherril
-
Henry, Charming solution. I had tried the BindingSource.ResetBindings()in several events but (silly me) I had never put it in the VisibleChanged event. I appreciate you. Sherril
My pleasure. :)
Henry Minute Do not read medical books! You could die of a misprint. - Mark Twain Girl: (staring) "Why do you need an icy cucumber?" “I want to report a fraud. The government is lying to us all.” Why do programmers often confuse Halloween and Christmas? Because 31 Oct = 25 Dec.