How remove focus to the list box? - visual-c++

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)
}

Related

How do I change format on ActiveX Control Option Button when selected?

When I select the ActiveX Control Option Button the entire border (box) becomes highlighted. Is there a way to fix this, perhaps change something in Properties, so when I select the button nothing is highlighted?
It is not clear what you mean by "select the button".
If you mean to click on it, have you tried setting the "TakeFocusOnClick" property to False?
Once you've set the property, click the DesignMode button to get out of Design Mode.
The original question is about a "control option button" which is presumably the Option Button. While the 'Command Button' has a TakeFocusOnClick attribute, the Option Button surprisingly does not. Neither does the Check Box.
This property does not appear on the Properties list on the worksheet in Design Mode or on the auto-complete list in the VBA editor, even though they will both take focus on click.
NOTE: ActiveX buttons are far more flexible than the stock "form controls" that appear at the top of the 'Insert' dropdown panel.

Excel/VBA - Set Focus and Scroll to Control

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!

How to mark a multiple selection on a DataGrid control?

I've got a custom control based on a Datagrid. What I want to achieve is doing multiple selection of rows and then right click on the row selector to open a context menu.
What actually happens: Selection of multiple rows works fine until the user right clicks on the row selector. Once that is done, there is only one selected row the one over which the right mouse button was clicked.
What I need to happen: Allow the user to do a multiple selection (rows have a style for selection) and right click to open the context menu without loosing the previous selection.
What do I need to do?
No it doesn't happen like that at all. Make sure that you have DataGridView MultiSelect property set to TRUE. Then assign your ContextMenustrip control to the datagrid's ContextMenuStrip property.
That should do the work and multiple selection should remain on right mouse click as well unless in your code behind somewhere you are altering that.
In which case, you will have to debug and find out where and how.
Just revisited the code and found that I was not updating the SelectedItems IList:
Dispatcher.BeginInvoke(new Action(delegate
{
foreach (var item in e.RemovedItems)
{
SelectedItems.Add(item);
}
SelectedItemsList.Add(SelectedItem);
}), System.Windows.Threading.DispatcherPriority.ContextIdle, null);

MFC Ribbon CEdit Textbox Allignment in Panel

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.

Adding a scroll bar to a label

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

Resources