Datagrid programmatically unselect a cell - winforms

I am using a PDA in which I have a DataGrid that has a list of itemNames, barcode, and scanStatus. The user scans a barcode and I search in my DataGrid for a match and I select the row for the item that is associated with the barcode. I set the scanStatus to true.
I was having a problem with the user touching the screen and the DataGrid's rows all got unselected.
So I tried to handle the DataGrid's Click, DoubleClick, and the MouseUp events. I loop through my grid where scanStatus is true and call grid.Select(iteratorIndex) else I call grid.UnSelect(iteratorIndex).
This re-selects the scanned item's rows. But the last cell that the user clicked also stays selected. How do I unselect that cell? I did search before posting and the only thing remotely matching my situation was this thread, I tried the advice there but it but that did not answer my question.

Related

DatagridTemplateColumn.CellEdit selection changed

I have a ComboBox in a DataGridTemplateColumn.CellTemplate. When editing an existing entry the UpdateSourceTrigger=PropertyChanged fires on property change. However, I want it to fire on a new line as well just as if I have press (clicked) in any of the cell to start new entry.
By the way I am not using DataGridTemplateColumn.CellEditingTemplate for editing but DataGridTemplateColumn.CellTemplate which I thinks looks better unlike the default
In MS documentation it says DataGridCell.Selected Event Occurs when the cell is selected. That means when one presses a KeyDown or mouse click in the cell. I guess what I want is how to select a cell through a ComboxBox selection changed event. I want when I select a record in the combobox to begin the a new line just as if I have started typing soemthin in any of the DataGrid cells.

On Click on the RowHeader the current row should be editable and On click of the columnHearder current column of all row should be editable

I have a silverlight DataGrid, by default on page load the all the cells of the datagrid should be Readonly. I have 2 problem , can any one help me?
1.On Click on the RowHeader the current row should be editable
2. On click of the columnHearder current column of all row should be editable
This might not solve your entire problem but it should partially address it.
This is to make a column read-only in a datagrid
DataGrid.Columns[7].IsReadOnly = true;
Obviously the property can be changed from events but the data grid does not have row/column headers event handlers. Custom controls seem the way to go without introducing any new gui elements like buttons and changing the feel of the application.

Not selecting item in combobox

I need the following behavior for WPF Combobox:
i need autofilter in combobox. Took the implementation from here. But when there are several items in dropdown that are almost same-when i press DOWN it just selects the first one from list and hides others(see video of current behavior here: http://www.youtube.com/watch?v=_WYAgMTxc4M). If i want the second possible-i have to select it with mouse or write down the whole item display name in editable part of combobox. Is it possible to select item without changing editable part of the combobox, until i press ENTER, for example?
I think that problem is when you select the item, it fill the text area of ComboBox, than it notify that filter text changed and it applied new filter for the list, and the only one item remains in the list.
You should to rewrite this behavior that will apply filter only if KeyPressed / KeyDown / KeyUp events was fired.

Datagrid Row Selection On Button Click In WPF

I am having a Datagrid that gets populated with values from a DataTable. In my program i have four buttons: Goto First, Last, Next and Previous, as the name name indicates i have to select the rows based on the selection made using these buttons. Everything seems well if i use the below code to get the row (for example first row).
DataGridRow row =(DataGridRow)userControl.m_DataGrid.ItemContainerGenerator.ContainerFromIndex(0);
row.IsSelected = true;
But the code throws null value when there is more rows than the height of the Datagrid(When scrollbar comes into picture).
Please help me out of this issue. I think this is because of the view problem.
Due to virtualization the containers are only created when the object is in view, so you could first scroll the item into view using the respective method, wait for the creation of the container and then select it.
As this is rather messy i would suggest binding the IsSelected to a property on your item using a style for DataGridRow (set it as ItemContainerStyle). Then you can just set the property to true and scroll the item into view if need be.

WPF DataGrid selected row stays highlighted even when user clicks another control

Is it possible to turn off the selected row highlighting when a user clicks another control in the window?
Thanks in advance.
You could set the SelectedIndex to -1 in the LostFocus event, thus losing the selected item and removing the highlight.

Resources