By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
454,703 Members | 1,400 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 454,703 IT Pros & Developers. It's quick & easy.

What is easiest way to do this?

P: n/a
What is the easiest way to do this. I have a field in a Winform where I
want either and only a Y or an N (or perhaps a null).

One way is to use a combobox with a drop down list. Is there another? What
about a regular text field with a picture statement on it. Does the VS text
field support this? What are my options?


Nov 20 '05 #1
Share this Question
Share on Google+
4 Replies


P: n/a
Woody,
In addition to a combobox w/drop down list, you can use a list box.

I would consider using a CheckBox, I would enable three state on the check
box for null.

You could also use a set of RadioButtons.

With CheckBoxes & RadioButtons you would need to 'translate' from boolean
values to Y or N. This might be easiest by deriving from CheckBox or
creating a UserControl with RadioButtons.

Hope this helps
Jay

"Woody Splawn" <wo***@splawns.com> wrote in message
news:el**************@tk2msftngp13.phx.gbl...
What is the easiest way to do this. I have a field in a Winform where I
want either and only a Y or an N (or perhaps a null).

One way is to use a combobox with a drop down list. Is there another? What about a regular text field with a picture statement on it. Does the VS text field support this? What are my options?


Nov 20 '05 #2

P: n/a
Hello,

"Woody Splawn" <wo***@splawns.com> schrieb:
What is the easiest way to do this. I have a field in a
Winform where I want either and only a Y or an N
(or perhaps a null).


Why not use a CheckBox control (have a look at its 'ThreeState' property).

--
Herfried K. Wagner
MVP VB Classic, VB.NET
http://www.mvps.org/dotnet
Nov 20 '05 #3

P: n/a
Thank you for responding
I would consider using a CheckBox, I would enable three state on the check
box for null.


Actually, this is what I am trying to avoid. If I use a 3-state check box it
forces the user to to consider what a null is etc., and in this case I think
it would be better to just give them a Y or N option.

With regard to doing this with a Drop down list, there are a couple of
things I don't understand. I have a Y/N (null) field scenario on a
Winform. I am using a combobox for this. I have DropDown Style set to drop
down list and in the Items collection I have Y and N. However, I have yet
to discover the combination of other properties that will allow me to
selecte either the Y or the N or to leave the field blank. I would like to
be able to leave the field blank and if left blank have it considered a
null. Is this possible? Right now, it will not allow me to enter anyting
into the field except a Y or an N.

Also I do not understand how to bind this field at design time. In the
databindings property I have three choices; selected Item, Selected Value
and Text. Which of these do I choose? I have tried all of them but they
all seem to have their quirks. If when the record first comes to the screen
there is a Y in it, if I choose a N instead and save the record, the N is
replaced by the Y. Don't understand why.

Am I using the right tool?

Nov 20 '05 #4

P: n/a
Woody,
If you have a Drop Down combo box and you want three options of Y, N or
blank. Add those three to the list.

ComboBox1.Items.Add("")
ComboBox1.Items.Add("Y")
ComboBox1.Items.Add("N")

Normally I wound bind to SelectedItem or SelectedValue depending on what is
contained in the list. (are they simple strings as above, or is there actual
objects in the list).

Remember if you are binding to a database field and that field is Boolean,
then you cannot bind to the string per se, I don't have an example, I
suspect will need to bind to an object that translates the string being
displayed and the boolean being stored.

Hope this helps
Jay

"Woody Splawn" <wo***@splawns.com> wrote in message
news:%2***************@tk2msftngp13.phx.gbl...
Thank you for responding
I would consider using a CheckBox, I would enable three state on the check box for null.
Actually, this is what I am trying to avoid. If I use a 3-state check box

it forces the user to to consider what a null is etc., and in this case I think it would be better to just give them a Y or N option.

With regard to doing this with a Drop down list, there are a couple of
things I don't understand. I have a Y/N (null) field scenario on a
Winform. I am using a combobox for this. I have DropDown Style set to drop down list and in the Items collection I have Y and N. However, I have yet
to discover the combination of other properties that will allow me to
selecte either the Y or the N or to leave the field blank. I would like to be able to leave the field blank and if left blank have it considered a
null. Is this possible? Right now, it will not allow me to enter anyting
into the field except a Y or an N.

Also I do not understand how to bind this field at design time. In the
databindings property I have three choices; selected Item, Selected Value
and Text. Which of these do I choose? I have tried all of them but they
all seem to have their quirks. If when the record first comes to the screen there is a Y in it, if I choose a N instead and save the record, the N is
replaced by the Y. Don't understand why.

Am I using the right tool?


Nov 20 '05 #5

This discussion thread is closed

Replies have been disabled for this discussion.