If I fill a ListBox with items, will a vertical scrollbar automatically appear when there are too many items to display, or is there something that needs to be set for this to occur?
ListBox only shows a vertical scroll bar when there are more items then the displaying area.
You can play with ListBox.ScrollAlwaysVisible Property if you want the bar to be visible all the time.
YES, that it will.
Related
I have a DBGrid in my form that contains many items. Now I have tow the problems:
1- if items count in my DBGrid is less, I shouldn't be have vertical scrollbar.
2- when I click on each cell in DBGrid, Scrollbar start moving. while scrollbar should be start moving to down when I want to see (hidden or bottom) Items in the list. I couldn't find any options in DBGrid Properties for fix this solution.
Picture of first problem: (show vertical scrollbar with less items)
Picture of Second problem: (Moving Scrollbar after click on DBGrid cells)
In this picture, scrollbar should be start moving down when I want to show Item 25
The Best Solution for fix these issues is use NextDBGrid6 component from bergsoft.
I am using RAD Studio 2010 on Windows 10. Is there any way to create a vertical toolbar for Delphi VCL projects? Something similar to what is shown in the attached picture (right side, top to bottom, on main window):
I need selectable items.This mean changing in back color in clicking or when mouse move over it
You can do this with a TListView. Assign your images to a TImageList, and assign that ImageList to the ListView.LargeImages property. Add an item for each image you want to display using the Items property (or right-click on the ListView and choose New Item from the context menu), assigning the proper caption and imageindex for each item. Make sure the ListView.ViewStyle is set to vsIcon, and the ListView.ItemOptions.AutoArrange is set to True.
Here's a sample of the result of a quick test app with a few random images I added - just a few 32x32 images in the Win10 style, courtesy of Icons8. It shows the highlighted Button 3 item as the mouse pointer is hovering over it.
The only drawback to using the TListView is that if the dialog is sized so that all items in the ListView aren't visible, the ListView will display a vertical scrollbar automatically. You'll want to make sure that you leave enough space for that scrollbar just in case, or restrict your window's MinHeight constraint to prevent it from being resized too small. On the other hand, if you want to display more than one item in each row, it's easily accomodated with the TListView - just widen the control to allow more items per row, and the AutoArrange property will take care of everything.
I have a THorzScrollBox in a form, and some TStyledControls inside. Each StyledControl has a Tag to identify. Using an TEdit to inform a value, I can find inside the ScrollBox an specific Control by his tag.
If the control that I searched is not on the screen, I want to scroll the ScrollBox to show it.
How can I do this programmatically?
I found a way to do this.
I have to use ScrollBy. But the detail is that if I want to scroll the controls to right I have to use a negative value.
Example:
sbItems.ScrollBy(-10, 0); // this will scroll to right
If I use a positive value, it will scroll to left.
sbItems.ScrollBy(10, 0); // this will scroll to left
The point is, if you scroll once, the ViewportPosition will change and the next time you execute ScrollBy, it will not reset the scroll position, it will scroll from the point you already have scrolled.
I have a DBGrid on a form. The DBGrid has many columns, so an horizontal scroller is displayed. I scroll the DBGrid view to the right to see more columns. If I select a row, the DBGrid view is automatically reset to view the first column (As if I scroll back to the left most position).
Is there a way to prevent that?
I assume you have goRowSelect in the grid options. This forces the selected col to be the first non-fixed column, so whenever the row changes the code to scroll the selected cell into view forces the first non-fixed column to be visible.
Since goRowSelect also effectively disables the horizontal scrolling with the keyboard I try to live without it. You can use custom drawing of the grid cells to show all cells of the current row with the proper colours for selected cells, even though only one cell is really selected. I use this also to show different colours depending on whether the grid is focused or not, similar to what a standard tree control does. For this to work properly you do however need to handle not only grid cell navigation events, but some other events too, like OnEnter and OnExit of the grid, OnActivate and OnDeactivate of the Application, and so on.
You might be able to ask for the scrollbar position
GetScrollInfo(Self.Handle, SB_VERT, SIOld);
and use SetScrollInfo( ) to put it back. There's probably a better way. SelectedField is another way (get/set it as needed).
I have a DBGrid on a form. The DBGrid has many columns, so an horizontal scroller is displayed. I scroll the DBGrid view to the right to see more columns. If I select a row, the DBGrid view is automatically reset to view the first column (As if I scroll back to the left most position).
Is there a way to prevent that?
I assume you have goRowSelect in the grid options. This forces the selected col to be the first non-fixed column, so whenever the row changes the code to scroll the selected cell into view forces the first non-fixed column to be visible.
Since goRowSelect also effectively disables the horizontal scrolling with the keyboard I try to live without it. You can use custom drawing of the grid cells to show all cells of the current row with the proper colours for selected cells, even though only one cell is really selected. I use this also to show different colours depending on whether the grid is focused or not, similar to what a standard tree control does. For this to work properly you do however need to handle not only grid cell navigation events, but some other events too, like OnEnter and OnExit of the grid, OnActivate and OnDeactivate of the Application, and so on.
You might be able to ask for the scrollbar position
GetScrollInfo(Self.Handle, SB_VERT, SIOld);
and use SetScrollInfo( ) to put it back. There's probably a better way. SelectedField is another way (get/set it as needed).