<div dir="ltr"><div dir="ltr"><div dir="ltr"><br></div><br><div class="gmail_quote"><div dir="ltr" class="gmail_attr">Il giorno sab 2 feb 2019 alle ore 20:54 T Lee Davidson <<a href="mailto:t.lee.davidson@gmail.com">t.lee.davidson@gmail.com</a>> ha scritto:<br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">...<br>
Charlie, thank you for that code. Setting the column width to -1 does automatically resize the column to fit the data. However, <br>
I am trying to achieve the behavior that the Expand property is supposed to give: "Return or set if a GridView column <br>
automatically expands to fit the GridView width." Meaning, as I understand it, similar to AutoResize but for a column other than <br>
the last column.<br>
<br>
I have actually accomplished this by capturing the sum of the column widths within the For loop and then resizing the first <br>
column mathematically within the Arrange event. It would seem, though, that using the Expand property would be much simpler and <br>
more sensible.<br>
<br>
<br>
___<br>
Lee<br></blockquote><div><br></div><div>If with "Charlie" you're referring to me, also me can not get Expand to work.<br>But I think you can easily replace it with Width = -1:<br>'-------------------------------<br>Public Sub Form_Open()<br><br> Dim Headers As String[] = ["0123456789", "0123456789", "0123456789", "0123456789"]<br><br> With GridView1<br> .AutoResize = False<br> .Header = GridView.Horizontal<br> End With<br><br> GridView1.Rows.Count = 1<br> GridView1.Columns.Count = Headers.Count<br> For i As Integer = 0 To Headers.Max<br> GridView1.Columns[i].Title = Headers[i]<br> GridView1[0, i].Text = String(30, "*")<br> Next<br> GridView1.Columns[0].Width = -1<br><br>End<br>'-------------------------------<br>But also I would be curious to know how to set Expand ;-)<br><br>Regards<br>Gianluigi <br></div></div></div></div>