I was wondering if there is anyway to check if the up arrow or the bottom arrow of a wpf scroll viewer is clicked.
I am trying to do it within a wpf textbox but, I want it to snap to the next line of a text instead of displaying partial text.
So, the way for me to do this is when up/ or down is clicked.
i would say
textBox.lineup/linedown.
but I also need to know which component is clicked in order to do so.
Thanks in advance!
-Kevin
You can use ScrollChanged event in ScrollViewer as below
<ScrollViewer ScrollChanged="ScrollViewer_ScrollChanged">
In code you can get the verticalOffSet value.
private void ScrollViewer_ScrollChanged(object sender, ScrollChangedEventArgs e)
{
double verticalOffSet = e.VerticalOffset;
...
}
Related
I use a textbox as an address bar for a WP browser application. I want to select all text when a user selects the textbox and also to modify the opacity.
I tried using GotFocus method to do that. I see that the whole text is selected for 1 second or so and then it is deselected. I also need to modify the opacity once the focus is on textbox and when the textbox loses focus. Using GotFocus method I can modify the opacity but when the focus is lost, when I set again the opacity percent nothing happens.
Can you give me a hint regarding the events that determine the text to be selected for a short period of time and for the opacity problem?
private void URLTextBox_GotFocus(object sender, RoutedEventArgs e)
{
URLTextBox.Opacity = 50;
URLTextbOX.SelectAll();
}
private void URLTextBox_LostFocus(object sender, RoutedEventArgs e)
{
URLTextBox.Opacity = 10;
}
You can try subscribing to one of the tunnelling events (PreviewGotKeyboardFocus and PreviewLostKeyboardFocus) instead of the GotFocus event.
Is there any trivial way to handle click event on the splitter area of the WinFroms splitcontainer control? (symbolized by blue in my picture) E.g. I'd like to collapse panel1 by double clicking this area.
Or another possibility to put some nice button in this area and by clicking it I can collapse panels.
I don't wanna great hack to make a soulution, it would be nice to have a trivial one.
Thx
(.net 4/c#/VS2010)
You should be able to use the SplitContainer.DoubleClick event for this purpose..
splitContainer1.DoubleClick += splitContainer1_DoubleClick;
and
private void splitContainer1_DoubleClick(object sender, EventArgs e)
{
splitContainer1.Panel1Collapsed = true;
}
If you want the location of the click, use MouseDoubleClick event which comes with MouseEventArgs for the event handler.
You mean besides the SplitContainer's Click event?
How to change dropdown button in a ComboBox control (C#, Windows Forms)? I have a custom button, and I want to use it in the ComboBox instead of the default dropdown button.
I think Hans Passant solution is the way...
From here:
http://social.msdn.microsoft.com/forums/en-US/winformsdesigner/thread/5d65f987-834c-465f-a944-622831d4cfb0
You can create a UserControl, drag a
ComboBox and a Button onto it, make
the Button right over the ComboBox's
arrow button to make the arrow button
invisible, handle the Button's Paint
event to draw an arrow on it, this can
be done by calling
ComboBoxRenderer.DrawDropDownButton()
method (Notice: this method has a
limit, it needs the visual style being
enabled on the OS) or by drawing an
icon on it, or just drawing a small
triangle on it.
Then handle the Click event of the button to show the ComboBox's
DropDown, this can be done by
something like this
private void button1_Click(object sender, EventArgs e)
{
this.comboBox1.DroppedDown = true;
}
I have a tab control and need to remove the dotted focus rectangle around the selected tab.
I have set the TabStop property of the TabControl to false. However if I click on a tab and press the Tab key, the dotted rectangle appears around the tabname.
I have tried creating my own TabControl and tried this
class MyTabControl : TabControl
{
public MyTabControl()
{
TabStop = false;
DrawMode = TabDrawMode.OwnerDrawFixed;
DrawItem += new DrawItemEventHandler(DoMoreTabControl_DrawItem);
Invalidate();
}
}
However, the dotted rectangle still appears.
I also tried overriding the MyTabControl.OnPaint() method but it doesn't help.
Is there any way to achieve this?
Set the focus to tab instead of header (like this)
private void tabControl1_Click(object sender, EventArgs e)
{
(sender as TabControl).SelectedTab.Focus();
}
You will see dotted rectangle for a millisecond, as soon as the above event gets executed it will disappear.
Also, to remove dotted rectangle for default selected tab on load
private void tabControl1_Enter(object sender, EventArgs e)
{
(sender as TabControl).SelectedTab.Focus();
}
Both this changes worked for me!
hope it helps somebody.
Yes, DrawItem event. You didn't post it, impossible to guess what's wrong with it. Just make sure that you don't call e.DrawFocusRectangle(), likely to present when you copied the MSDN sample code. Simply deleting the statement is sufficient. Consider using a different background color or text font style as an alternative so the focus hint isn't entirely lost.
I have a check box that is disabled that should be showing a tooltip when hovered over, but instead nothing happens. Once the checkbox is clicked on the tooltip shows momentarily then flashes on and off very fast. What could be causing this?
The tooltip should also be showing for every control involved, but shows for some and not others eventhough the tooltip is explicitly set for all controls. What could be causing this behavior?
Here is the event handler:
this.MouseHover += new EventHandler(OrderSummaryDetails_MouseHover);
void EventHandler_MouseHover(object sender, EventArgs e)
{
if (someCondition)
{
this.mFormTips.Show("Please open order form to manually modify this order", this);
}
}
I can't be positive, but if using WinForms, and you have your checkbox disabled (as in not enabled), then the checkbox will not receive events. This will cause tooltips not to show up properly.
I had the exact same problem before with a image button and what I ended up having to do was to create a gray scale of the image and swap it out when I wanted the button to be "disabled". I had to add the tooltip to the button and the image (two separate UI elements) and swap out the UI elements.
I added a MouseMove event and applied it to all the controls.
void OrderSummaryDetails_MouseMove(object sender, MouseEventArgs e)
{
Control control = GetChildAtPoint(e.Location);
if (control != null)
{
string toolTipString = mFormTips.GetToolTip(control);
this.mFormTips.ShowAlways = true;
// trigger the tooltip with no delay and some basic positioning just to give you an idea
mFormTips.Show(toolTipString, control, control.Width / 2, control.Height / 2);
}
}