Combobox selection control not coming out - c#

I'm working with winforms comboboxes. When I select any item in combobox I've raised an event. But control can not come outside. When I scroll the mouse the selected event changing every time.
how to prevent this?

The mouse scrolling actually does change the item selection in the combobox and hence your event is fired, you don't want your event handling code on mouse scroll?

If the problem is that you cannot use the mouse wheel to open drop-down portion of the combobox, then you can use ComboBox.DroppedDown property.

Related

How to get the clicked event of a wpf data grid?

I have a DataGrid with programmaticaly added rows (items) by adding an ItemSource.
I do not want the user to edit the cells so I set IsReadOnly = true;.
But I want them to click on cells and output which cell was clicked.
I was searching for a Clicked event and was surprised there is no such event for a DataGrid. I want a behaviour like buttons where it doesn't matter if it's clicked by the mouse, space bar, enter or whatever else the system accepts as a "Click".
So how can I achieve that?
Whatever is in the cell template (TextBlock, for instance) could be styled to handle the PreviewMouseUp event and pull the information you want from the control or bound object. The click event is specific to Button, TextBox and other controls that deal with mouse capture. Here is a link that discusses the dilemma you are facing: http://blog.scottlogic.com/2008/12/02/wpf-datagrid-detecting-clicked-cell-and-row.html. He provides examples on how to accomplish the task at hand.

ListView LostFocus Event isn't working fine

I've a listview and a textBLOCK inside it. I want to collapse the visibility of listview when I tap anywhere else on my screen. I tried to do this using LostFocus Event for my listview but it is fired ONLY when I selected an item. Why does it behave like that?
Thanks in advance!
The only way to do this as of right now, based on this seems to be to hook into the touch input directly from the CoreWindow and then each time compare the point on the touch input with the bounds of the ListView relative to the CoreWindow.
The WinRTXamlToolkit may assist in this by adding such extensions as GetBoundingRect to FrameworkElements.
I used the IsTabStop Property. Actually i have a user control in in which i'm having this Listview. I did the following steps:
I set the IsTabStop property of UserControl to "True".
Then I set the focus to the textblock when it is tapped by doing:
this.Focus(FocusState.Pointer);
Then created the LostFocus Event of my UserControl and Collapsed the visibility of ListView.
Try using TextBlock's Leave or LostFocus event because if you focus the TextBlock, the ListView losts focus but if you focus TextBlock when you focused something out of ListView, the ListView never becomes focus.

WPF: How do I handle mouse click on a Listview inside of a Button?

I have a listview for displaying a table inside of a button. I have a click event assigned to the button, but when the user clicks on the list view, a row is selected on the list view and the mouse click is never bubbled up to the button.
I'm stuck at this point, and need a way to solve this. All the examples I've seen online are for placing a button inside the listview. How do I make this work?
Set the IsHitTestVisible property to false on your ListView. Since it is a control that normally processes click events, doing this will have it ignore them.
If you don't want the items to be selectable in the first place, you could make the List View unable to receive Focus. Just set the Focusable property to false.
With the List View unable to receive focus, then I would expect the mouse event to bubble up to the button.

Getting value of Combobox on Hover c#

I'm trying to make an application where I have this combobox that automatically opens and closes on mouse enter and mouse leave events respectively and then gets the value of the combobox before i leave it.
I already have the dropdown behavior as given by someone who posted it online. But now I need to get the value of my combobox item without clicking the mouse. I've tried selectedvalue or selecteditem but all seems to require mouse clicking. Is there any way of getting the value of the combobox where the mouse points to before I leave/close the combobox?
You can use labels for the combobox items.
Add 'MouseMove' event and in the event take the label text.
Here is an example how to implement very closely connected behavior: ComboBox MouseLeave MouseEnter.

WPF Listview/Gridview setting selected item when combobox is clicked

I'm having issues using a GridView as a ListView's View, what I want to do is fire an event when a user makes a selection from a combobox within the Gridview and pass the selected item within the event.
My first issue is that when the user clicks the combobox within a row, the row isnt selected (meaning the selecteditem stays null unless they click elsewhere first). Is there a clean way to do this without trying to catch mouse clicks or anything?
Secondly theres no selectionchangecommited event on a WPF combobox, is there a cleaner way to check if a user has manually selected an option other than checking if the combobox is enabled?
Thanks
I am seeing a similar behavior. My hypothesis is that one or more layers of the DataTemplate of each item in the list is swallowing the RoutedEvent that should have resulted in a new selection. Is it possible to, in a generic way, tell the items in the DataTemplate that they should never stop the event from bubbeling or tunneling further, without having to override every focus-triggering event handler in code behind?
I 'solved' my issue by using the WPF Toolkit grid (http://wpf.codeplex.com/Release/ProjectReleases.aspx?ReleaseId=29117) and a series of selected items, which is probably a cleaner solution anyway.
Doesn't explain the behavior of the GridView, which is to me unusual
Original link has died, believe this to be the one https://github.com/xceedsoftware/wpftoolkit/wiki/DataGrid

Categories