I have a datagrid that imports data and this data is affiliated with columns, my concern is that I have 2 radio buttons and I would like when I select a radio button the other on the same line is automatically deselected. I tried to find the solution but still no find so I ask for your help Thank you!
It depends what UI framework you use:
For WinForms:
https://stackoverflow.com/a/3851776/18990321
For WPF:
You should use the GroupName property.
https://wpf-tutorial.com/basic-controls/the-radiobutton-control/
Related
Here's my issue : I need to build a C# application with WPF where the users can select numerous lines from a DataGrid. But, despite the fact I put the selection mode to "Extended" I'm only able to select a single row from the GUI.
I thought I could circumvent this problem by programmatically select the row the user clicks, but again I can only select one row at time ! I searched a lot on the internet but didn't find a simple way to select multiple rows in a datagrid
I'm a beginner with WPF and I'm not very good with DataBinding and MVVM pattern, so if the the answers could be simple it'd be perfect !
Thank's a lot !
I finally used the checkboxes method, referring to this article : http://www.scottlogic.com/blog/2008/11/26/multiselect-datagrid-with-checkboxes.html
It works great and it's really easy to implement. At least the part with the checkbox. I put the CanUserResizeRows property to false, which resolved the issue with the gripper !
Changing the selection mode and selection unit should most probably fix your problem. It's working in my case.
In you XAML, set you following DataGrid attributes:
SelectionUnit="FullRow"
SelectionMode="Extended"
This should work.
You can Add Template column for CHECKBOXES for selection.
refer this Multi-select ASP.NET datagrid to get complete solution.
By default, you need hold shift and click to select multipe rows, really make no sense. Most people chose the check box approach. But wpf don't give you a simple option.
I need to put a RadioButton against each Row in a DataGrid view . But Iam unable to find a control like DataGridViewRadioButtonColumn just like DataGridViewTextBoxColumn . So how should I go about doing it ? Thanks in Advance
(User can only select one radio button)
You will have to create your own custom Cell and Column to implement this functionality.
There is an excellent article on MSDN that describes this scenario almost exactly. It shows you how to create a custom radio button cell that supports multiple radio buttons per cell. The code could easily be adapted to allow just one radio button per cell.
The article is written for Visual Studio 2005, but should work equally well for VS2008 and VS2010.
I want my ListBox to have columns, and one of those columns have to be a clickable URL.
How can I achieve this?
You can't do it in a ListBox. You can create your own control, or settle for another existing one. Based on the question, I'd guess you're not yet at the stage where you're creating your own controls. That takes a pretty good understanding of existing controls and the way they work under the covers (but a google search for creating Winforms Controls should yield plenty of instructions.) Edit added It looks like te 4th and 5th links in combination on that google search should get you what you need. You can create your own user control and then do an array of them)
As far as for other possible alternatives, have you considered a DataGridView? A DataGridView can have a hyperlink and it can have checkbox columns, so this would be one possible alternative.
Here's a link for having a Hyperlink column in a DataGridView.
Well, it is possible by using the CustomTabOffsets property (unreliable) or the DrawItem event. And implementing the MouseDown event to find out if that particular 'column' was clicked.
But there's little point, a ListView control with View = Details gives you the same functionality.
There is option called checkedListBox1 for check box group item..
Like that any control for radio button. and how to bind my data(data set) in that.
User container to have same functionality as like group name.
container can be group box or Panel
There is no such thing for radio buttons. You may, however, look for third party controls or extend the existing CheckedListBox so that only one item at a time can be checked.
The second solution is a bit ugly, because seeing check boxes the user would expect to be allowed to select more than one option.
Put the radio buttons in their own panel, and they will work together, with only one button in the panel being selectable.
As for data-binding, there are several approaches available, such as creating a form Boolean property for each option, and binding each radio button to its property.
An easier approach would be to use Jay Andrew Allen's RadioPanel, which takes care of binding the radio button options to an enumeration field.
I have 2 questions concerning C#.
1) I have a dropdown menu with several items in them. They are clickable, but when I click one, the older clicked one stays selected. Click another and the 2 original ones stay selected, and so on. I don't want this. What I want is that when I click one of the dropdownitems, that one is that selected one and the others are not.
2) I have a listview items on a winform. I loaded some string elements into it from a file. Now what I want to do is to be able to edit those strings and even add strings, just by clicking on the rows in which the data goes.
I've checked google and MSDN for these problems, but nothing helps, so I turn here.
2) The ListView does not support that type of action. You can roll your own (pain in the #$$), or perhaps a DataGrid would be better suited to your purpose.
EDIT:
This link may help
This one too
For #1 I'm a little confused. If the DropDownStyle isn't set to simple something strange is occuring. It's not much but maybe you could try recreating the control.
For #2 the easiest solution I can think of is to set a TextBox to be equal to the selected text value from your listview. After that write a little function to update the selected index of the listview with the edited text from the listview.
Please comment if you have any more information about #1.