Cannot gain focus on controls - winforms

Something stops controls from getting focus with TabKey. The form has a 2 paged XtraTabs, a few group boxes and mostly txtBoxes.
I have set the tab order with the taborder tool. I also tryied it manually.
Something doesnt work.
When I first hit tab, does not even go to the next control (from the tabpage header). Even if I click on a txtbox and press tab, nothing happens.
Any idea on what's wrong with this?

Related

WPF - Loading Window inside User Control

I use DevExpress tab control.
At the moment, when a user does something that takes some time, such as generating something etc, I have a window come up with text "Saving ..." that essentially disables the MainWindow while the operation is in progress.
This obviously doesn't let them continue on doing something else in the meantime.
I'd like that they could simply click on another tab and do something else.
An example done in paint :) :
User presses 'Do Something' button.
Tab1 is now disabled until 'Something' is done.
Tab2 however, is not.
Ideally it hovers over the usercontrol rather than pushing stuff out of the way/making them invisible.
EDIT: The text needs to be editable. I.e. If I'm looping through products for example, ideally I write 'Processing Product 0/100'

RichTextBox scroll to end not working when not visible

I have a WPF RichTextBox in my application that sits in Grid. It gets updated every second or two as it displays logs (though sometimes there are no logs for up to a minute depending on the load).
The grid is not always visible, as it sits in its own tab. If the user is on another tab, the logger is not visible.
My problem is that I want the RichTextBox to scroll to the end every time a new paragraph is added. It seemed simple as there is a 'ScrollToEnd' method on the RichTextBox control and so I call that method every time text is added to the control.
The problem is that that method only works if the control is visible, if the user is on another tab, the RichTextBox will not scroll to the end and it looks weird when you click on the tab with the logger and after a couple of seconds or longer it scrolls to the bottom when it should already be at the bottom.
Is there a way around this annoying "feature" of the control? I would like to ALWAYS have the RichTextBox be at the bottom unless the user is manually taking control of the scroll bar.
Thanks!
By default, the TabControl actually doesn't change its contents visibility, it removes them from the view completely when you change tabs and then "re-attachs" them when you navigate back to the previous tab.
That's why the Visibility change doesn't get fired. Instead, you should handle the Loaded event, which should get fired right before the view is re-rendered.
Is there a reason you cannot simply call ScrollToEnd in response to the text box becoming visible? That seems like the simplest approach. Did you try it and run into an issue?
Edit: If you are using a TabControl, each TabItem has an IsSelected property you can bind to from the ItemContainerStyle. You could probably scroll your text box in response to the tab becoming selected.
As a separate note: if you are planning to make a custom control for this, here are some things to consider.
I wrote an auto-scrolling version of a FlowDocumentScrollViewer. (I never needed a RichTextBox specifically, but they display similar content.) I can tell you that there are a lot of things to account for, such as knowing when and when not to auto-scroll based on what the user is currently doing.
For example:
If the user takes over the scrolling themselves via the scrollbar or mousewheel, you don't want the control to fight with them.
If they start selecting text, you don't want to scroll it away from them mid selection.
If they scroll to the bottom, you probably want it to start auto-scrolling again.
Also, determining what the user is doing to begin with can sometimes be a complex process on its own.

How to prevent the keyboard cover over the UI in windows phone?

The project is based on wp 7.5.
I have a grid, and when the user swipe it, a textbox will reveal and the keyboard will show.
The function is ok, but there is a little bug, when the system keyboard show, it will cover over the textbox, so the user can't see the stuff they have entered.
how to solve it?
It would be best to position such a textbox so that it would not be obscured when the keyboard is shown. This is typically done by placing it at (or near) the top of the page.
Depending on how you've structured your XAML the default behaviour of the phone should scroll the content so that it is not obscured by the keyboard. Without being able to see you code I couldn't say why this isn't happening.
Alternatively you could but the page content inside a ScrollViewer and manually scroll it so that the TextBox is visible when it has focus.

Can anyone explain why this behaviour might be happening in Windows Forms?

I'm developing a Windows Forms Application. See attached image for the Interface. Now I've put a close button (X) in the Panel(say Panel2) which has Application Constants as label.The first combo box is in another panel(say Panel1). Now when I click on the X button in Panel 2 I want the Panel to be invisible and the combo box text to be blank. Simple enough.
So I write
Panel2.visible=false;
comboBox1.SelectedIndex=-1;
When I click on X, the text in combo box goes blank, then I have to click again for the Panel2 to go invisible.
Then I changed the sequence
comboBox1.SelectedIndex=-1;
Panel2.visible=fasle;
and this works smooth. Not sure why this might be happening? Is there anything that I might be doing with my form design/code to have such a behaviour?
I expect that you have an event handler on comboBox1 for SelectedIndex changed, which makes the panel visible for some reason. Moving the setting of selectedindex before the hiding of the panel fixes this.

ComboBox doesn't raise keyboard and mouse events as expected

I use Silverlight 4.0 and have got problems with ComboBox control. I want to implement a popup menu which will show and hide itself without clicking mouse. It should show when I place cursor on its region - this prt works well. Then it should hide whenever mouse pointer is placed outside of its region for a while. I implemented it with MouseEnter and MouseLeave events. My problem is ComboBox - this control behaves weirdly, in my opinion. Normally I would expect it to raise MouseEnter event when I put the cursor on it and MouseLeave when I put the mouse cursor anywhere else. The real situation is different: Whenever I click the combobox, it opens and shows the list of options, and immediately sends LostFocus and MouseLeave events. So it seems like the control lost keyboard focus and mouse pointer has been moved out of its region, while actually the combobox list of optins is open and active and has keyboard focus in it.
So the question is how can I know in my program what is happening in comboboxes? In order to correctly hide my popup menu, I need to know when the list of options in a combobox is open or closed. I can't see any events for this or any other documentation. (Wanted behavior is: If a combobox is closed, I hide my popup menu based on the position of mouse cursor. If a combobox is open, I never hide my popup menu until user either selects something in the combobox, or closes the combobox.)
Also, if you have got a good experience with a third party combobox replacement, which looks and works similarly AND raises events I need, please let me know.
MSDN has two events listed for ComboBox that you might want to look at.
http://msdn.microsoft.com/en-us/library/system.windows.controls.combobox_events(v=VS.95).aspx
DropDownClosed Occurs when the drop-down portion of the combo box closes.
DropDownOpened Occurs when the drop-down portion of the combo box opens.

Resources