473,397 Members | 1,974 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,397 software developers and data experts.

What is easiest way to do this?

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
4 3237
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
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
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
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 thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

4
by: J Sharman | last post by:
What is the easiest way to import an XML Datafeed from a URL into a MYSQL Database? Possibly using PHP Regards Joe PS Please answer to group and joe@joesharman.co.uk
5
by: Christian Seberino | last post by:
In c extension what is easiest way to build a (PyObject) list from an array of doubles? I don't think I can do "return Py_BuildValue(...) to make a list from an array can I??? How else can I...
7
by: Dan V. | last post by:
Situation: I have to connect with my Windows 2000 server using VS.NET 2003 and C# and connect to a remote Linux server at another company's office and query their XML file. Their file may be...
1
by: Henry | last post by:
I have a large number of user define class objects and want display in a datagrid and able to perform paging and column sorting. It seems using DataView is the easiest way but the objects are not...
7
by: hazz | last post by:
What happens if I set the timer interval for a period that is less than the time it will take to process the loop below? Right now my application is returning just a few items in an arraylist to...
0
by: NotGiven | last post by:
I want to add some shopping pages to my site. I'd lilke to use the easiest things possible, thought I am a PHP developer. What's the easiest way to add a "web store" using Amazon web services or...
6
by: QQ | last post by:
I have a string A I'd like to print A except for for(i=offset-1;i<100;i++) printf("%c",A); or introduce a new variable like B memcpy(B,&A,100-offset) printf("%s",B); What's the easiest way...
4
by: gnewsgroup | last post by:
I have a membership web application. A user is either an administrator or a regular user (only 2 roles) I have an admin folder in this application. I want only administrators to be able to...
8
by: Pierre Dagenais | last post by:
What is the easiest way to draw to a window? I'd like to draw something like sine waves from a mathematical equation. Newbie to python.
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.