I have a label on a userForm and the data within it is in list form. The data is longer than the label. Without expanding the label, is there a way to add a scroll bar to it? Or is there another option? Basically I want a box that does not have a scroll bar unless the list is longer than the box, then there's a scroll bar.
Using Excel vba userForm
You can used a textbox styled to look like a label. Set it to multiline with scrollbars set to vertical. Scrollbars will only show up if the content exceeds the size.
You can't have scroll bar for label, instead a textbox can be used.
Set textbox with "Enabled" and "Locked" properties as"true". User will then have a scrollable and noneditable view
For vertical scrolling, set "WordWrap" and "MultiLine" to True
Now you could view the scroll bar on tapping the textbox. If you want the scroll bar to be visible by default, on the form load event we need to set the focus of textbox as below:
Private Sub UserForm_Initialize()
errorText.SetFocus
End Sub
Related
I'm using a UserForm in Excel VBA and I have a combo box with style fmStyleDropDownList. I want to remove the horizontal scrollbar:
Picture of my combo box with ColumnWidths of 100 pt. The combo box shown has a Width property of 162, a ColumnWidths property of 100 Pt and a ListWidth property of 162 Pt.
Keep in mind that this problem is somewhat similar to this one:
Remove the scroll bar on a list box. In this post, the accepted solution states:
This can occur when you have the column width format property of the listbox set to something wide, then you size the control to the data, it will show the scroll bars.
To fix this, change the "Column Width" property under the format tab to something really small, then play around with this property and the size of the listbox control until you get it how you want, and no scroll bars are displayed.
So what I did is: I changed the ColumnWidths property to smaller values until the horizontal scroll bar disappears. However, this has the side effect that the drop down text has not enough width to be displayed as a whole as it is shown in the following Pictures (the Width and LastWidth property remain at 162):
Picture of my combo box with ColumnWidths of 50 pt. The scroll bar is still there. Instead of "abcdefghijklmn", only "abcdefghijkl" (without mn) is dislayed in the second row of the drop down menu and in the third row it says "something e" instead of "something else". I assume this is because the ColumnWidths property is set too small.
Picture of my Combo box with ColumnWidths of 18 pt. The scroll bar is gone (which is what I want). 18 pt is the biggest value I came up without having a scroll bar. But it now displays only a few (18?) points in any row of the drop down menu which is unacceptable to me.
Any ideas how to solve this?
As Siddharth Rout pointed out, the problem was due to multiple columns. Setting the ColumnCount property back to 1 solves this issue.
I'm looping through the ActiveX controls on my spreadsheet to implement tab control. I have around 100 controls in my spreadsheet, so not everything fits on a single "page" (it's all in the same tab, you just have to scroll down.)
I can use Activate to set the focus to the next control. However, when I tab through the controls and pass the bottom of the viewable window, the window doesn't automatically scroll to show the control with focus.
Is there a way to get the spreadsheet to scroll so that the control that has focus is actually on the screen?
Sorceri nailed it right on the head. I used Window.ScrollRow to scroll down the page after I set the focus. The only issue is that this sets the bottom of the row to the top of the window, so it's just off screen. I was able to resolve this by specifying:
ActiveWindow.ScrollRow = row-3
Thanks!
I sub-classed a combo-box control to make text vertically centred. Issue here is I am getting a vertical scroll bar when only 3 or 4 items exists in the combo-box that too when I expand the control for the first time, where a vertical scroll is not required.
Control property had been set as follows.
COMBOBOX IDC_COMBOBOX,28,45,205,65,CBS_DROPDOWNLIST | CBS_OWNERDRAWNFIXED | CBS_HASSTRINGS | WS_VSCROLL | WS_TABSTOP.
When I removed WS_VSCROLL vertical scroll bar is not coming. But if I remove this property I will not get a scroll bar when too many items exists in the combobox, where actually a scroll is required.
Please find the below Images for your reference how the control is behaving.
Run the MFC application.
Expand the combobox.
Again try expanding the combo box issue is not reproducing. It's happening only
for the very first time when expand the control.
I could not figure out why this issue is happening. I tried removing the existing control and again I tried adding new controls expecting whether it could bring any change in the behaviour but no luck.
Item height is set to 30 as below.
m_ComboBox.SetItemHeight(-1, 30);
And I had two combobox controls in my properysheet application as shown in the image.
Any help is appreciated.
I am having a lisbox where I had set it's property "Selection" to "None".This lisbox is being used in a propertysheet.When I navigate on to the page where list box control is present,here initially when I click on the listbox no selection is happening,this is excepted result.But my only concern is in the lisbox page itself when I use "tab" usually the rectangular dotted line is coming on the Back,Next and Cancel buttons(this is expected),but at the same time after playing with tab around on those buttons,if I had a mouse click on the list box I am getting a rectangular selection on the Item's in the listbox(this is not expected),No selection has to occur.
I even set the "Tab shot" property of the list box to FALSE.
Can anyone please let me know how can I avoid that rectangular selection on the listbox items,even after using "tab" and having a mouse click on the lisbox that rectangular selection should not happen.
Must be a glitch... If you want to prohibit selections on your listbox without disabling it, what happens if you try
void CMyPropertyPage::OnSelchangeList()
{
m_list.SetCurSel(-1)
}
I am trying to align two text boxes with two buttons in a panel, and I am unable to find anything about how to force positioning inside the MFC Ribbon Panels.
Here is a picture of what I have currently.
http://i.imgur.com/ofD0b.jpg (Sorry wont let me post images yet, have to link.)
The Change View Date box has the box associated with it sitting below it and the change system date box is up in the top right in the second "column" of controls. I would like to fix this so the Box with the spin controls sits next to the CHange View Date and the box without the controls sits next to Change System Date.
Thoughts? Thanks!
I think yow cannot do it.
What you can do is to put a Ribbon Separator after the Box with the spin controls and then set the property 'Center Column Vertically' on the Panel.
Hope it can help.