[Gambas-user] GridView Cell Height with WordWrap
Rolf-Werner Eilert
rwe-sse at osnanet.de
Tue Mar 2 08:51:43 CET 2021
Am 01.03.21 um 11:14 schrieb Gianluigi:
> Hi Rolf,
> I thank you for the question about the _GridView_Cell.WordWrap property
> which allowed me to go deeper into the subject.
> I would like to make a couple of considerations with you.
>
> First of all, I would avoid looping the rows directly in the Form_Open()
> routine, as I wrongly proposed, because it forces to read all the cells
> and therefore if you have many columns it slows down the code.
> If you want to use GridView_Data, better if you cycle the column where
> WordWrap is useful in the Sub Form_Activate(), if desired, it also
> allows you to show a ProgressBar.
>
> But, with WordWrap, I would also avoid using the GridView_Data routine
> because this routine is primarily meant for large amounts of data and in
> this case it is best to avoid WordWrap and rely on
> GridView.Columns.Width = -1.
>
> In summary, if you have little data you can use WordWrap such as:
> '-----------------------------------------
> Public Sub Form_Open()
>
> With GridView1
> .Header = 3
> .Columns.Count = 2
> .Columns.Width = 100
> .Rows.Count = 100
> End With
> For r As Integer = 0 To GridView1.Rows.Max
> For c As Integer = 0 To GridView1.Columns.Max
> If r Mod 2 = 0 Then
> GridView1[r, c].Background = &HBFFFBF
> GridView1[r, c].Text = "Liber tempor"
> Else
> GridView1[r, c].WordWrap = True
> GridView1[r, c].Text = "Lorem ipsum dolor sit amet,
> consectetuer adipiscing elit, sed diam nonummy."
> Endif
> Next
> GridView1.Rows[r].Height = -1
> Next
>
> End
> '-----------------------------------------
>
> If you have a lot of data, use GridView_Data and Columns.Width such as:
> '-----------------------------------------
> Public Sub Form_Open()
>
> With GridView1
> .Header = 3
> .Columns.Count = 2
> .Rows.Count = 100
> .Columns.Width = -1
> End With
>
> End
>
> Public Sub GridView1_Data(Row As Integer, Column As Integer)
>
> If Row Mod 2 = 0 Then
> GridView1.Data.Text = "Lorem ipsum dolor sit amet, consectetuer
> adipiscing elit, sed diam nonummy."
> Else
> GridView1.Data.Text = "Liber tempor"
> GridView1.Data.Background = &HBFFFBF
> Endif
>
> End
> '-----------------------------------------
>
> In the hope of not having written some nonsense
> Gianluigi
>
>
> ----[ http://gambaswiki.org/wiki/doc/netiquette ]----
>
Yes, but... When I can set .Data.Background within _Data, why not just
set Data.Height = -1 here too? Because it affects the whole Row and not
only one cell?
If it really makes so much a speed difference to set this AFTER the
_Data event has spread the individual cell data, then it should be at
least be explicitely mentioned in the help for the Data event to warn
off anyone who is unaware.
Regards
Rolf
More information about the User
mailing list