If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below. |
|
|
Thread Tools | Display Modes |
#1
|
|||
|
|||
Resetting a listbox value and scrolled position
Hi all,
I'm working on implementing a 'Reset' button on my form. All the controls on the form reset properly, but I can't find a way to reset the scrolled to position of a listbox. To reset the listbox I've used lstItem.Value = 0 This works to clear all the selected items in the list. However, the scroll position does not change. I'd like to set the position of the scroll bar back to the top when I reset the form. If anyone has any idea how I can do this, I'd appreciate it. Also (as a bonus question) if anyone knows how to autosize column widths in a list box, pass it on. I'm using A97 and it's not a property. Thanks, Jay |
#2
|
|||
|
|||
Resetting a listbox value and scrolled position
Requery the list box. It will clear any selections made and position it back
to the first entry in the list. Me.MyListBox.Requery I don't believe there is any way to "autosize" columns in a list box. You can programmatically set the column widths using the columnwidths property. "Jay" wrote: Hi all, I'm working on implementing a 'Reset' button on my form. All the controls on the form reset properly, but I can't find a way to reset the scrolled to position of a listbox. To reset the listbox I've used lstItem.Value = 0 This works to clear all the selected items in the list. However, the scroll position does not change. I'd like to set the position of the scroll bar back to the top when I reset the form. If anyone has any idea how I can do this, I'd appreciate it. Also (as a bonus question) if anyone knows how to autosize column widths in a list box, pass it on. I'm using A97 and it's not a property. Thanks, Jay |
#3
|
|||
|
|||
Resetting a listbox value and scrolled position
Klatuu,
It doesn't work. The selection and position in list box remains unchanged. Would the fact I'm using A97 matter? Jay (I accidentally hit the button saying it answered the question). "Klatuu" wrote: Requery the list box. It will clear any selections made and position it back to the first entry in the list. Me.MyListBox.Requery I don't believe there is any way to "autosize" columns in a list box. You can programmatically set the column widths using the columnwidths property. "Jay" wrote: Hi all, I'm working on implementing a 'Reset' button on my form. All the controls on the form reset properly, but I can't find a way to reset the scrolled to position of a listbox. To reset the listbox I've used lstItem.Value = 0 This works to clear all the selected items in the list. However, the scroll position does not change. I'd like to set the position of the scroll bar back to the top when I reset the form. If anyone has any idea how I can do this, I'd appreciate it. Also (as a bonus question) if anyone knows how to autosize column widths in a list box, pass it on. I'm using A97 and it's not a property. Thanks, Jay |
#4
|
|||
|
|||
Resetting a listbox value and scrolled position
I don't know. I haven't worked in 97 since about 1999. I don't see why it
should. Is yours a single select or a multi select list box? I tested this on a multi select (I don't use single select list box. The combo box is much better at that) "Jay" wrote: Klatuu, It doesn't work. The selection and position in list box remains unchanged. Would the fact I'm using A97 matter? Jay (I accidentally hit the button saying it answered the question). "Klatuu" wrote: Requery the list box. It will clear any selections made and position it back to the first entry in the list. Me.MyListBox.Requery I don't believe there is any way to "autosize" columns in a list box. You can programmatically set the column widths using the columnwidths property. "Jay" wrote: Hi all, I'm working on implementing a 'Reset' button on my form. All the controls on the form reset properly, but I can't find a way to reset the scrolled to position of a listbox. To reset the listbox I've used lstItem.Value = 0 This works to clear all the selected items in the list. However, the scroll position does not change. I'd like to set the position of the scroll bar back to the top when I reset the form. If anyone has any idea how I can do this, I'd appreciate it. Also (as a bonus question) if anyone knows how to autosize column widths in a list box, pass it on. I'm using A97 and it's not a property. Thanks, Jay |
#5
|
|||
|
|||
Resetting a listbox value and scrolled position
Yes, it's a multi select listbox.
The Requery does clear al selected items from the list, but the listbox doesn't return back to the top of the listbox. So if I scroll to the bottom and use Requery, the item is no longer selected, but the litbox is still at the bottom. Thanks for your help though. Jay "Klatuu" wrote: I don't know. I haven't worked in 97 since about 1999. I don't see why it should. Is yours a single select or a multi select list box? I tested this on a multi select (I don't use single select list box. The combo box is much better at that) "Jay" wrote: Klatuu, It doesn't work. The selection and position in list box remains unchanged. Would the fact I'm using A97 matter? Jay (I accidentally hit the button saying it answered the question). "Klatuu" wrote: Requery the list box. It will clear any selections made and position it back to the first entry in the list. Me.MyListBox.Requery I don't believe there is any way to "autosize" columns in a list box. You can programmatically set the column widths using the columnwidths property. "Jay" wrote: Hi all, I'm working on implementing a 'Reset' button on my form. All the controls on the form reset properly, but I can't find a way to reset the scrolled to position of a listbox. To reset the listbox I've used lstItem.Value = 0 This works to clear all the selected items in the list. However, the scroll position does not change. I'd like to set the position of the scroll bar back to the top when I reset the form. If anyone has any idea how I can do this, I'd appreciate it. Also (as a bonus question) if anyone knows how to autosize column widths in a list box, pass it on. I'm using A97 and it's not a property. Thanks, Jay |
#6
|
|||
|
|||
Resetting a listbox value and scrolled position
Jay,
I apologize. I gave you bad info. I had not set up my test properly, but now that I have, I see you are correct. The Requery does not take you back to the top; however, I found a way that does it. This is goofy, but it works: lngHigh = Me.MyListBox.Height Me.MyListBox.Height = 0 Me.MyListBox.Height = lngHigh "Jay" wrote: Yes, it's a multi select listbox. The Requery does clear al selected items from the list, but the listbox doesn't return back to the top of the listbox. So if I scroll to the bottom and use Requery, the item is no longer selected, but the litbox is still at the bottom. Thanks for your help though. Jay "Klatuu" wrote: I don't know. I haven't worked in 97 since about 1999. I don't see why it should. Is yours a single select or a multi select list box? I tested this on a multi select (I don't use single select list box. The combo box is much better at that) "Jay" wrote: Klatuu, It doesn't work. The selection and position in list box remains unchanged. Would the fact I'm using A97 matter? Jay (I accidentally hit the button saying it answered the question). "Klatuu" wrote: Requery the list box. It will clear any selections made and position it back to the first entry in the list. Me.MyListBox.Requery I don't believe there is any way to "autosize" columns in a list box. You can programmatically set the column widths using the columnwidths property. "Jay" wrote: Hi all, I'm working on implementing a 'Reset' button on my form. All the controls on the form reset properly, but I can't find a way to reset the scrolled to position of a listbox. To reset the listbox I've used lstItem.Value = 0 This works to clear all the selected items in the list. However, the scroll position does not change. I'd like to set the position of the scroll bar back to the top when I reset the form. If anyone has any idea how I can do this, I'd appreciate it. Also (as a bonus question) if anyone knows how to autosize column widths in a list box, pass it on. I'm using A97 and it's not a property. Thanks, Jay |
#7
|
|||
|
|||
Resetting a listbox value and scrolled position
Klatuu,
That's awesome, thanks! Works perfectly. I don't know how you managed to find that. I'm glad I posted because I never would have tried that. Excellent work! Jay "Klatuu" wrote: Jay, I apologize. I gave you bad info. I had not set up my test properly, but now that I have, I see you are correct. The Requery does not take you back to the top; however, I found a way that does it. This is goofy, but it works: lngHigh = Me.MyListBox.Height Me.MyListBox.Height = 0 Me.MyListBox.Height = lngHigh "Jay" wrote: Yes, it's a multi select listbox. The Requery does clear al selected items from the list, but the listbox doesn't return back to the top of the listbox. So if I scroll to the bottom and use Requery, the item is no longer selected, but the litbox is still at the bottom. Thanks for your help though. Jay "Klatuu" wrote: I don't know. I haven't worked in 97 since about 1999. I don't see why it should. Is yours a single select or a multi select list box? I tested this on a multi select (I don't use single select list box. The combo box is much better at that) "Jay" wrote: Klatuu, It doesn't work. The selection and position in list box remains unchanged. Would the fact I'm using A97 matter? Jay (I accidentally hit the button saying it answered the question). "Klatuu" wrote: Requery the list box. It will clear any selections made and position it back to the first entry in the list. Me.MyListBox.Requery I don't believe there is any way to "autosize" columns in a list box. You can programmatically set the column widths using the columnwidths property. "Jay" wrote: Hi all, I'm working on implementing a 'Reset' button on my form. All the controls on the form reset properly, but I can't find a way to reset the scrolled to position of a listbox. To reset the listbox I've used lstItem.Value = 0 This works to clear all the selected items in the list. However, the scroll position does not change. I'd like to set the position of the scroll bar back to the top when I reset the form. If anyone has any idea how I can do this, I'd appreciate it. Also (as a bonus question) if anyone knows how to autosize column widths in a list box, pass it on. I'm using A97 and it's not a property. Thanks, Jay |
#8
|
|||
|
|||
Resetting a listbox value and scrolled position
Thanks for the Kudos.
All I did was open the Object Browser and start looking at all the properties and methods of a List Box and think about what they will do. When I go to the Height property, it dawned on me I had a form where 8 list boxes start with a height of 0 and are only resized when the user clicks a command button. Then I played with it and realized that every time I reopened one of the list boxes that had enough entries to require a scroll bar, it was always positioned at the top when I resized it. "Jay" wrote: Klatuu, That's awesome, thanks! Works perfectly. I don't know how you managed to find that. I'm glad I posted because I never would have tried that. Excellent work! Jay "Klatuu" wrote: Jay, I apologize. I gave you bad info. I had not set up my test properly, but now that I have, I see you are correct. The Requery does not take you back to the top; however, I found a way that does it. This is goofy, but it works: lngHigh = Me.MyListBox.Height Me.MyListBox.Height = 0 Me.MyListBox.Height = lngHigh "Jay" wrote: Yes, it's a multi select listbox. The Requery does clear al selected items from the list, but the listbox doesn't return back to the top of the listbox. So if I scroll to the bottom and use Requery, the item is no longer selected, but the litbox is still at the bottom. Thanks for your help though. Jay "Klatuu" wrote: I don't know. I haven't worked in 97 since about 1999. I don't see why it should. Is yours a single select or a multi select list box? I tested this on a multi select (I don't use single select list box. The combo box is much better at that) "Jay" wrote: Klatuu, It doesn't work. The selection and position in list box remains unchanged. Would the fact I'm using A97 matter? Jay (I accidentally hit the button saying it answered the question). "Klatuu" wrote: Requery the list box. It will clear any selections made and position it back to the first entry in the list. Me.MyListBox.Requery I don't believe there is any way to "autosize" columns in a list box. You can programmatically set the column widths using the columnwidths property. "Jay" wrote: Hi all, I'm working on implementing a 'Reset' button on my form. All the controls on the form reset properly, but I can't find a way to reset the scrolled to position of a listbox. To reset the listbox I've used lstItem.Value = 0 This works to clear all the selected items in the list. However, the scroll position does not change. I'd like to set the position of the scroll bar back to the top when I reset the form. If anyone has any idea how I can do this, I'd appreciate it. Also (as a bonus question) if anyone knows how to autosize column widths in a list box, pass it on. I'm using A97 and it's not a property. Thanks, Jay |
Thread Tools | |
Display Modes | |
|
|