New topic: Managing ListBox column widths..
<http://forums.realsoftware.com/viewtopic.php?t=37948> Page 1 of 1 [ 1 post ] Previous topic | Next topic Author Message BrianOBrien Post subject: Managing ListBox column widths..Posted: Fri Mar 04, 2011 1:47 pm Joined: Wed Jul 07, 2010 2:55 pm Posts: 211 Location: University Of Calgary, Faculty Of Medicine I have an extension to listbox that tries to format the listbox's column widths based on its contents and the column heading. A special character ":" is used as a column heading name to indicate that the column width should be zero (not displayed). This is almost behaving except the last column seems to be giving me some issues.... 1) If its a hidden column it still shows up (when it shouldn't) 2) The last column isn't displayed if the horizontal scroll bar is needed. Code:Sub AdjustColumnWidths(Extends lb as Listbox) dim r,c as Integer dim pic as new Picture(1,1,32) dim g as graphics = pic.Graphics dim w as integer dim colmax as integer dim cw as string = "" dim colmin as integer = 25 dim rows, cols as integer dim cc as string rows = lb.ListCount-1 cols = lb.ColumnCount-1 g.TextFont = lb.TextFont g.TextSize = lb.TextSize for c=0 to cols-1 'The last column occupies the remaining space. * if lb.Heading(c) = ":" then colmax = 0 else colmax = g.StringWidth(lb.Heading(c)) for r=0 to rows cc = lb.Cell(r,c) w = g.StringWidth(cc) if w > colmax then colmax = w next r if colmax < colmin then colmax = colmin end if if colmax <> 0 then cw = cw + str(colmax+8) + "," else cw = cw + "0," end if next c cw = left(cw, len(cw)-1) 'trim the extra , * if lb.sortedColumn > -1 then // the listbox is sorted by a column if lb.LastIndex > 0 then lb.sort// sort the listbox data using the current sort settings end if end lb.ColumnWidths = cw End Sub I've looked till I'm blue in the face and can't figure out why that last column is such a nightmare. I tried using the "*" for the last column, and maybe that is why? _________________ If at first you don't succeed... Try REALBasic. Top Display posts from previous: All posts1 day7 days2 weeks1 month3 months6 months1 year Sort by AuthorPost timeSubject AscendingDescending Page 1 of 1 [ 1 post ] -- Over 1500 classes with 29000 functions in one REALbasic plug-in collection. The Monkeybread Software Realbasic Plugin v9.3. http://www.monkeybreadsoftware.de/realbasic/plugins.shtml [email protected]
