if i resize a window i want to resize the height of my listbox too, this is easy done with the lock feature.
But the listbox should show additionally rows only if there is is enough space for a complete row(height), not only a part of it.
i tried with “Listbox.Height mod Listbox.RowHeight” to get the remaining height but i am stuck.
I misread your question yesterday; i recall I found that strange, but people sometimes ask what appears strange questions and often have good reason to ask.
Now that I think at your question - a genuine question - I do not / never asked it in my mind: I let the user to decide the window (thus the Listbox) height.
What I have done recently is to resize the Window Height to display - when possible - the whole Listbox contents (when a DataBase file have only a few number of Records to display), because I had enough to reside down the window in a Multi-Data Base List View displayer window. I used that method to do that (+ 1 empty line to be sure the last line is correctly displayed).
How did your code look like?[/quote]
No problem, I like to find answers to questions, that way I learn.
The code looks much like yours. I think you have a little bug:
a for you is only the distance between Listbox1 “bottom” and Window1 “bottom” and not the difference in Height
Listbox1 Open event:
a = Self.Height - Me.Height
For i As Integer = 0 To 25
Me.AddRow ("A row just for testing")
Next i
Window1 Resizing:
If CheckBox1.Value Then
Dim h As Integer = (Self.Height - a) Mod Listbox1.RowHeight
If h > 0 Then
Listbox1.Height= (Self.height -a) - h
End If
End If
the checkbox test is for demo purposes, this way I was able to activate/deactivate the option
Have you considered putting the code in Resized event instead of Resizing, that way it only ‘fix’ your Listbox how you wanted when the user let go resizing the window. If you do, you have to put Invalidate at the top of the Resized event if you are using mac so the windows contents are cleared before redrawing the listbox.