2011/9/26 Bruce Bruen <bbr...@paddys-hill.net>: > Thanks Fabian, > That (TextWidth) was what I didn't search for. > Got it working, but it is interesting that I have to "bump" the final > width value by an empirically determined amount to prevent the last > letter from being chopped. The code if anyone is interested is : > > ________________________________________________________________________ > Private Sub ReLoadList() > '' Reload the data in the gridview using the existing data set in > $cItems > > Dim wkItem As Todoitem ' working copy of the object to be > displayed > Dim idr, idc As Integer ' row and column indexes > Dim aItemValues As Variant[] ' working array copy of the object > values that are displayed > Dim aMaxW As Integer[] ' max column width array > > ' Set up > gvwList.Clear > gvwList.Rows.Count = $cItems.Count > aMaxW = New Integer[gvwList.Columns.Count] > > ' Initially set the max column width array values to the size of the > column titles > For idc = 0 To gvwList.Columns.count - 1 > aMaxW[idc] = gvwList.Font.TextWidth(gvwList.Columns[idc].Title) > Next > > ' Load the items from the source collection into the rows > idr = 0 > For Each wkItem In $cItems > With wkItem > aItemValues = > [.ID, .Project, .Affects, .Title, .Type, .Status, .Priority] > End With > For idc = 0 To gvwList.Columns.Count - 1 > gvwList[idr, idc].Text = aItemValues[idc] > ' and check to see if the max width value needs changing > If (gvwList.Font.TextWidth(gvwList[idr, idc].Text) > aMaxW[idc]) > Then aMaxW[idc] = gvwList.Font.TextWidth(gvwList[idr, idc].Text) > Next > Inc idr > Next > > ' Finally set all the column widths according the the values in the > max column widths array > For idc = 0 To gvwList.Columns.Count - 1 > gvwList.Columns[idc].Width = aMaxW[idc] + 7 > Next > > End > > ________________________________________________________________________ > See the last bit. I had to bump the computed value by 7 (for both gtk > and qt4) to stop the last letter being chopped.
in fact it's the column minimum padding that mask the letter > > regards > Bruce > > On Sun, 2011-09-25 at 18:53 +0200, Fabien Bodard wrote: > >> 2011/9/25 Bruce Bruen <bbr...@paddys-hill.net>: >> > I'm trying to set a gridview column width to the maximum length of the >> > strings in the column. I can find the maximum width in terms of the >> > length of the string easily but what do I multiply that by to get the >> > desired cloumn width? >> > I have searched through the wiki but I just cant seem to find what >> > replaces Desktop.Scale? >> why don't you use fontsize ? >> >> iWidth = GridView1.Font.TextWidth(iMaxLetters) >> >> > tia >> > Bruce >> > ------------------------------------------------------------------------------ >> > All of the data generated in your IT infrastructure is seriously valuable. >> > Why? It contains a definitive record of application performance, security >> > threats, fraudulent activity, and more. Splunk takes this data and makes >> > sense of it. IT sense. And common sense. >> > http://p.sf.net/sfu/splunk-d2dcopy2 >> > _______________________________________________ >> > Gambas-user mailing list >> > Gambas-user@lists.sourceforge.net >> > https://lists.sourceforge.net/lists/listinfo/gambas-user >> > >> >> >> > > > ------------------------------------------------------------------------------ > All of the data generated in your IT infrastructure is seriously valuable. > Why? It contains a definitive record of application performance, security > threats, fraudulent activity, and more. Splunk takes this data and makes > sense of it. IT sense. And common sense. > http://p.sf.net/sfu/splunk-d2dcopy2 > _______________________________________________ > Gambas-user mailing list > Gambas-user@lists.sourceforge.net > https://lists.sourceforge.net/lists/listinfo/gambas-user > -- Fabien Bodard ------------------------------------------------------------------------------ All the data continuously generated in your IT infrastructure contains a definitive record of customers, application performance, security threats, fraudulent activity and more. Splunk takes this data and makes sense of it. Business sense. IT sense. Common sense. http://p.sf.net/sfu/splunk-d2dcopy1 _______________________________________________ Gambas-user mailing list Gambas-user@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/gambas-user