How to lock combobox so that the text and items cannot be modified/delete/erased? - vb.net

Is it possible lock the combobox so that the text can not be deleted/erased or modified. And make only choose the items? Thank you in advance. Hope is it possible.

Set the "DropDownStyle" property of the combobox to DropDownList.
This will allow only items in the list to be selected and will not allow any user input:

Option 1
Simply set the ComboBox.Enabled to False - that way they can't change the values!
Option 2
Otherwise, use the dropDownStyle:
make DropDownStyle property to DropDownList instead of DropDown
For more information
Read this article (yes, it's written in c#, but the properties are the same!)
the above image displays this quite well.
EDIT
There is also a question previously asked here that asked a similar question.

You can set ComboBox.DropDownStyle to ComboBoxStyle.DropDownList.

Related

data from Gridview to textbox

i have a form with datagridview in vb.net that show my data in columns. what i'm trying to accomplish is that after choosing a row and pressing Edit button a new form will open and split the row for the right text boxes to update the data. the datagridview row shows different types of data: name,email,date,etc... any idea? Thanks in advance!
In the EditButton click-handler, you may access the selected row in your datagridview with the MyDataGridView.CurrentRow property.
This object - a DataGridViewRow - has Cells, which you can access individually by index and then get to their values:
...CurrentRow.Cells(n).Value
This then, in turn, you may use to fill the items in your edit form.
After completing your edit form, retrieve the (updated) values and put them back into the CurrentRow.Cells(n).Value
If your datagridview is databound, then you can also work directly with the datastore, through
...CurrentRow.DataBoundItem
The type of this object depends of course on your configuration; it may, for instance, be a DataRow.
This should be enough to get you going.
Final note on your added remark "thanks ...": you're apparently new at this site. I'm not sure why you got "downvotes". It may be because your question is rather elementary ("homework"), or people found your problem description not clear/detailed enough. Please, understand that answers (if any) are provided "unpaid for", and require "voluntary" effort from the contributors. Understandably they prefer that YOU do most of the work/study/trying, before asking someone else "to do your work for you". No offense intended.

vb datagridview columntype change on edit

is there a method of setting up my datagridview to show me textboxcolumns until editmode is entered? At which time I will swap some textboxcolumns for bound comboboxcolumns. And at the end of validation/exit edit mode I can swap back?
If there's a method of doing this please share some links to examples.
I wouldn't try to switch DataGridView ColumnTypes like that. Sounds like a bad time.
Is your goal to have a DataGridViewComboBoxColumn that does not display the ComboBox dropdown button when it's not being edited? If so, there are two options:
Set the column's DataGridViewComboBoxColumn.DisplayStyleForCurrentCellOnly property to True.
Create your own DGV column based on the ComboBox by extending DataGridViewTextBoxCell. MSDN has a great article for doing this with the Calendar control here.
Of course you can. In the properties of the datagridview you can drill down to the column proprieties and switch the datatype to combo box. Very straight forward and easy.

Binding to NSMatrix for BOOL attributes

I have a simple core-data entity that has a Boolean attribute called subscribedToNewsletter. I have designed my UI to represent this field as a radio button group with Yes/No as the text values (and obviously YES/NO as the backing BOOL values).
I have always considered myself to have excellent google-fu, but for the life of me, I am unable to find any clear documentation on:
how to bind the selected value of the NSMatrix (or is it the cell?) back to a YES/NO value
how to bind the textual values (if indeed I do need to; I know there are only ever going to be two values - surely they can be hard-coded in Interface Builder, or not?)
Next up will be how to bind a radio group (with Male/Female text) to a String field called gender that has M and F as possible values - but I digress.
Any pointers would be very much appreciated. Thanks a lot.
Not sure if I got no answers because a) it is such a stupid question, or b) no-one in the world knows how. The latter doesn't strike me as likely, so I can only presume the first :)
Anyway just in case there others as stupid as me, I thought I'd give some feedback on how I managed to achieve it.
In Interface Builder, I created a NSMatrix with two radio button cells with "Yes" and "No" as the text for each respectively. In the Attributes Inspector (command-1), make sure the Tag field is set to 1 for the "Yes" button cell, and set to 0 for the "No" button cell. Then, in the Bindings Inspector (command-4) bind the SelectedTag field for the matrix to the Boolean property on your entity. Easy as pie.
I make no claims that this is the best way... just that it is effective.
I have found one solution for this part-
how to bind the selected value of the
NSMatrix (or is it the cell?) back to
a YES/NO value
Here is the link to the problem which I faced and its solution- NSMatrix simple binding question
Hope this helps !

CheckedListBox VB.Net MultiExtended SelectionMode

I have a CheckedListBox with a few items and I want to allow user to select more than one using arrows keys or mouse clicks combined with shift and ctrl keys so I set SelectionMode property to MultiExtended.
In design time it is not possible I get an error:
value property is not valid.
and if I set it in runtime by doing:
clbEmployees.SelectionMode = SelectionMode.MultiSimple
I get an error too:
CheckedListBox is not compatible with multiple selection.
How could I do this?
It's not supported for the CheckedListBox.
However, I'm fairly sure that you could mimic that functionality in a ListView. Just look at the CheckBoxes and MultiSelect properties of the Listview. As far as I can tell from the documenation those are compatible.
This might be too late, but I just put my solution here; Works perfect for me:
1- Just leave the CheckedListBox Selection mode as "ONE' in property sheet.
2- in your code, loop thru the checked item in your checked Box using the checked item property as following:
For each XX as 'DataTpe' in CheckedListBox.CheckedItems
'Here you assign each checked item to wherever you want to direct to'
Next

DataGridView and Combobox Column?

when DataGridView has a combobox column, how can I get the text it displays as oppose to the value it represents? When I do DGV.Item("cbo",i).Value I get the value but it won't take DGV.Item("cbo",i).Text. I trying Ctype(DGV.Item("cbo",i),ComboBox).Text and this does not work either.
Try
DGV.item("cbo",i).DisplayMember
Umm are you talking about Win Forms?
If so, Value is the property you want, and is what is to be displayed on the screen and held behind the scenes.
If you want something different not shown to the user, I've often used the property Tag for that.
I found this, and the answers didn't work for me. In case someone else finds this, here is what I did.
dgv.rows(i).Cells(cboname.index).EditedFormattedValue
Hope if someone finds this through Google it will help them.
Dim dgvcmbcell As DataGridViewComboBoxCell = DgvItemsUnits.Item("UNIT_SER", 0)
Dim SelectedText As String = dgvcmbcell.EditedFormattedValue.ToString()