Get mousemove over Combobox popup list - c#

When my mouse moves to the bottom of Combobox popup list, the list automaticly start to scroll down. But when I'm the bottom and goes to the top, there is no autoscrolling effect so I want to disable this behaviour, couse it only work in one way, down..
I cannot find any property, so I try to get mousemove event on that dropdown-list to cancel it, or make it handled, but it is triggered only on combobox itself, not on the list.
I also try to create something on top of that list, such as invisible panel which gets mouse move events instead of that dropdown-list, but I cannot find anything useful, couse that list is always at the top of everything.
Another idea was to find an event which is executed when items which are shown in popup list are changed and stop it when the mouse didn't grab the scrollbar, or click it, but this is also immposible. No events triggered. there is only selectedchanged event, but this is trigger on select not on the scrool.
Is there any solution to do this?

Finally I found the answer!!!
I had about 26 lines in my Combobox List, that was liitle to big so I wanted to show only 7 of them per time.
I found DropDownHeight property, and set it: Property ItemHeight was set to 13, couse the Font.Size was 8,25 (default). 7*13 = 91. And set it.
.
And it works almost perfectly, but there was a problem with autoscrooling. (which I asked above)
Finally I realised that last line (here is NNN) is not fully shown. And when mouse Enters this line, the ComboBox Control want to show me whole line and scrolls it UP.
I started to change size and find out, that the line is being shown totally when it is set to 93 (= 7*13 + 2). Why 2? Probably because a bottom and top border. And now there is no autoscrolling...
I also find, that another possibility is to set:
ComboBox1.IntegralHeight = False;
ComboBox1.MaxDropDownItems = 7;
And this works only when there was no changes in DropDownHeight, default value in my case was 106 ( = 8*13 + 2) couse the default value of MaxDropDownItems is 8.

Related

Selecting and Deselecting overlapping graphics in silverlight

I am placing a line (lets call it line 1) on a canvas and attaching a mouse enter, mouse leave, mouse up and mouse down event to it. Another line (line 2) is then created with the same events attached. All events work perfectly when any of the lines are selected.
For some reason when the first line that was created is dragged and released over the second line created the line does not get released on the canvas, however it remains glued to the mouse pointer until another click is made away from the second line. This problem occurs when the earliest lines created are dragged over the newer lines and not vice versa ( problem occurs when line 1 is dragged and released on line 2 but not vice versa, or line 1 over 2 and 3, and line 2 over line 3 etc.
I do not know what code might help regarding the solving of this issue, would anyone have any suggestions or maybe have encountered a similar problem?
The reason for the observed behavior is quite easily deduced:
All elements in a Panel do have an implicit z-order that will take effect when no ZIndex property is specified for en element. Earlier added elements have a lower z-order than later added elements (xaml markup is parse from top to bottom and elements that occur earlier are added earlier).
Now if you start moving elements around and two elements overlap the z-order is still effective. so your earlier added line will be treated as if it is physically beneath the other line, and all mouse events will go to the top-most line in the z-order. therefore the MouseUp event is not received by your moved element and it is still glued to the mouse pointer until you move your mouse away from the overlapping area and release the mouse again.
I can think of several ways to solve it:
Probably the easiest thing will be to just set an explicit ZIndex on the element as soon as you select it, when you move it around it will always be on top of all other elements, and when you release it anywhere you can clear the ZIndex again. Some example code to give you an idea:
private void OnElementSelected()
{
// todo: maybe we need to store the previous zindex value and re-assign it later
// to prevent it from getting lost
Canvas.SetZIndex(this, Int32.MaxValue);
}
private void OnElementReleased()
{
this.ClearValue(Canvas.ZIndexProperty);
// todo: maybe re-assign stored z-index value
}
An alternative solution would be to have a transparent MouseEventObserver placed over your whole Canvas that gets activated as soon as you select an element, then the order of your elements doesn't matter.
Edit
A nice fact (many devs probably are unaware of) about the Canvas.ZIndex attached property: it works for every panel type, not only for Canvas. So you can even specify the z-order of elements inside a Grid with Canvas.ZIndex.

Why can I not click a small CheckedListBox?

I have created a CheckedListBox control with 4 elements in C#. Multicolumn is set to true. As soon as I make the height of the control small enough to contain only a single row, I can no longer interact with the control with the cursor when I execute the program. If I make the height one unit (pixel?) larger, so that there are 2 columns of 2 rows, behavior returns to normal.
When the cursor cannot interact with the CheckedListBox, I can still tab to it, toggle between its elements with the arrow keys, and check/uncheck elements with the space bar. I just cannot use the cursor.
Looks like a bug to me... I'm experiencing the same thing occasionally. It happens when (1) the CheckedListBox is 1 row high, and (2) the items in it extend ANY past the right edge of the control. If the control is made a little wider, the mouse clicking works again. (You can test that theory by anchoring the CheckedListBox Left/Right and resizing the form. Now it works, now it don't.)
Seems like setting the width to be total column width + 4 also works.
There is a minimum width such that all columns are fully displayed that must be met before you can interact with it via mouse cursor.

Get text box's scrollbar position

I have a text box whose content is constantly changing and whenever that happens, the scrollbar automatically resets back to the top (not just the text box, another list view of mine behaves in the same manner). Is there anyway to save the current scroll position and then load it later? It's annoying to have to scroll the textbox/listview all the way down everytime the change occurs.
This behavior only occurs when you are using a normal TextBox with "multiline" set to true. If you use a RichTextBox instead, the scroll bar position will not change when new text is added.

How to check if mouse is over selected area in mschart

In my WinForms application I have Chart control with those settings:
chartArea.CursorX.IsUserEnabled = true;
chartArea.CursorX.IsUserSelectionEnabled = true;
chartArea.AxisX.ScaleView.Zoomable = false;
where chartArea is main (and only) ChartArea object in my Chart control.
What I am trying to do is posibility of selecting area (it is possible already), and when mouse is over this area, if I left click chart cotrol inside that selected area, I wan't it too zoom in.
First problem here is how to detect if I am over selected area ? with chart.HitTest() i can get HitTestResult.PointIndex field value and compare it with selection range. But this only works, if mouse is exactly over DataPoint. So it doesn't work for SeriesChartType.FastLine which I am using.
If this gets somehow solved, next will be problem with selection cancelation after mouse click (before Click or MouseXXX events are called).
SOLVED
I've found axis.PixelPositionToValue() method, which gives me every info I need, because from MouseMove event arguments I have pixel position.
For click events problem I'll write another question.
http://www.bigresource.com/VB-Using-MsChart-MouseOver-Event-to-display-the-contents-of-array-that-populated-chart-ydWJntrg8c.html
Though this is VB.NET, the concept is the same. I think.

What is the easiest way to make tooltips behave how I want

I don't like the default ToolTip behavior. First, I don't like that, after tooltip is shown for "AutoPopDelay" miliseconds, it disappears and don't appear anymore if you move the mouse over the control again. Second, I don't like that AutoPopDelay is limited to 5000 miliseconds.
I found one way to make tooltip always reappear on mouse move over control, even if it was shown for a time exceeding AutoPopDelay value: I call toolTip.Hide() in MouseLeave handler. This way tooltip will appear again on mouse over.
But I haven't found a simple way to make tooltip stay shown for longer time (longer than maximum 5000 miliseconds). If I call toolTip.Show() in MouseEnter handler, then toolTip is shown in not good position. I like the position in which it shows automatically :)
So, what can you suggest?
Use the Show method to control the length of time (it is not limited to 5000ms).
There is a signature for Show that does not require that you set the relative coordinates and there is one that will take the coordinates if you want to fine-tune things. In your case you will need to pass coordinates (if you don't like what it automatically gives you). I do not believe there to be an alternative...

Categories