Adding Multi-Select Functionality (Java Developer Learning C#) - c#

I'm working on a piece of code that I inherited and am trying to expand it from only being able to select one row to being able to select multiple rows.
Essentially, the item I'm working with displays like a data table. It contains methods for "OnSelectItem" and "OnMouseDown", with "OnMouseDown" checking to see if the click is right mouse button click or a left mouse button click.
Generally, how is functionality to support the ability to support Multi Select implemented? Is it handled through recognization of the mouse clicks in addition to holding down particular keys or is there a different way to implement this type of functionality?

Your comments indicate that you're working with a custom control. So, answers that apply to general Microsoft-supplied controls may not work at all.
You should be able to use the events you've listed already to handle multi-select features in this custom control.
As an example, you could look at the CheckedListBox control. It has a checkbox in front of every row. If the box is checked, that row is "selected". If that's not the type of selection you're looking for, then you can look at the ListView control in Detail mode. It allows you to set options that let the user highlight multiple rows, using CTRL and/or SHIFT to modify the way the mouse-click affects selection.

As far as multi select is concerned from my point of view it also requires key board support in addition to mouse click
1) In Controls if we press shift key and then press up or down arrow key then also row get selected
2) We can also implement multi select functionality by checkbox column, i am not sure this is possible or not in your case
3) There is also fundamental of Fixed Column, on mouse click of that column entire row is getting selectd

Related

How to create a custom selectionmode in winforms listbox

I have a listbox in a winforms application that I would like to give a selection behavior that is different than the built in options for the control.If I choose multi-extended, I get what we are accustomed to - ability to use shift or control to select multiple items in the list. The multi-simple option lets you select individually and leave the item selected until you delect it. I'm trying to deal with a slightly different problem that could be solved by a combination of the two options. My users want to be able to use the shift key to highligh a long list and they don't want to accidentally lose their selection if they mistakenly click on one other item in the list. My thought was to keep everything hightlighted until they click a clear button. I kind of think they are asking for something that is not what Windows is meant to do and should not be allowed to do but I thought would post the question so see if anyone has done this before.

Is there a way to select individual cells?

I am working on a project in C# on the .net micro framework, using the GHI Glide graphical library. I need to navigate a DataGrid through the use of directional keys and a numeric keypad (and NO touchscreen). There is an enter button which I am using to activate what I call "Edit DataGrid Mode", where I call the following on the DataGrid myGrid (which selects row 10, for example, and colors it yellow): myGrid.SelectedIndex = 10;
Problem is, I would like to be able to enter into a "Edit Cell Mode" when I click the enter button again, but in the DataGrid class, there doesn't seem to be any way to show a cell is selected. I thought about using a popup window that would get the data from the cell and then proceed from there, but I would rather avoid popups in favor of a more streamlined approach.
Am I missing something about how I could trigger touch events to make a cell select? Or should I just go the hardcore route and use something similar to window.Graphics.DrawTextInRect(...); to make a text rectangle appear over the cell I am editing?
Change the selection unit property of the Datagrid. Selection Mode would be the alternative to your problem if selection unit is already on cell.
Thanks for your help, but I found that the GHI Glide graphical library for .net micro framework does not have this capability, and other ways of inputting data must be used (sorry for the confusion, there wasn't a tag for Glide). I ended up using a TextBox component to serve as a background and adding other components on top of it, setting the text of those components as I retrieved data from the table.

Winforms UI Dynamically Displaying Parts

I came across a tutorial and some example code for an audio converter. You select the format you want to convert to from a drop down, and when you do all sorts of options appear in a previously blank area, different options based on the format you choose. It's called Audio Converter .NET and is from same author as Audio CD Ripper .NET. I can't find the tutorial, but here is a screenshot.
See how on the right there is extra controls that are not on the left. I was experimenting trying to add another category. I added it to the dropdown, but am unsure how to make it so certain fields come up when it is selected.
I understand that they create those controls for those items, but I don't see how they call the correct one when the combo box selects something. I see controls are created, but if I try to duplicate the controls into another entry in the combo box they don't show up for either the new or old one I was duplicating from.
What's the best way to go about achieving something like this?
Thanks
The easiest way is to create the controls needed for every option in the dropdown inside a panel, and simply turn it's visibility property from false to true whenever it's corresponding option is selected using the combobox's SelectedIndexChanged event handler. (And don't forget to turn the current visible panel's visibility to false)

How do i disable the ability to deselect a record on a WPF Datagrid

I am working on implementing a WPF Datagrid and I have a requirement where a record in the grid must always be selected. I have set the SelectionMode=Single and SelectionUnit=FullRow. However if i click and drag a given record while pressing control i am able to enter a state where the grid no longer has a selected value. It looks like by pressing control i am able to get the record to deselect. I have tried handling the preview key down event and setting handled to true when the control key is pressed but it seems to be an order of operations issue between click/dragging the records and the control key being pressed. Ultimately i would like to just disable the whole click/drag the grid selection, but i am coming up short on that one. I am trying to keep this as clean as possible. Does anyone have any experience with this?

Replace left click behavior by ctrl-click behavior in a datagridview

I would like a DataGridView row selection to behave the same way than when holding the ctrl button down (Click a new row to add to selection, click again to deselect, etc.) But I want it using the left mouse button.
Can I set this behaviour or will I have to do it programmatically ?
I believe the DataGridView class does not support this type of behavior out of the box. In other words, you're going to have to do it yourself, which offhand does not seem all the difficult to do.

Categories

Resources