473,418 Members | 2,340 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,418 software developers and data experts.

Binding a GroupBox

TS
Hi everybody,
I posted this question before but got a strange response from someone.
Anyways, is it possible to bind a GroupBox that includes multiple check
boxes to a column in a SQL database? Yes or No.

If it's yes, when the user checks one of these check boxes, what value will
be stored in the column? I'm really confused about that. Please help.
If there is any white paper about this, it will also be helpful.
--
TS
Nov 23 '05 #1
5 2778
TS,
I believe the answer you got for the first post was no, this cannot be done
as you describe it.

You probably need to manually assign a value to each checkbox. Associating
specific database vales to each checkbox when loading/saving data would also
have to be done manually, probably by looping through the check boxes and
checking each one as you load/save data. This isn't too bad if you know in
advance what checkboxes you want to display.

If you want to add checkboxes based on data, this can be done
programmatically, but I am not the one to explain how to do it. For
example, you have a field "fruit" in the database with 3 values (apple,
orange, grape), and you want 3 checkboxes. Someone adds a value (peach) to
the database, now you want the app to display 4 checkboxes. Is this what
you are trying to do?

AFAIK means As Far As I Know.
"TS" <TS@discussions.microsoft.com> wrote in message
news:08**********************************@microsof t.com...
Hi everybody,
I posted this question before but got a strange response from someone.
Anyways, is it possible to bind a GroupBox that includes multiple check
boxes to a column in a SQL database? Yes or No.

If it's yes, when the user checks one of these check boxes, what value will be stored in the column? I'm really confused about that. Please help.
If there is any white paper about this, it will also be helpful.
--
TS

Nov 23 '05 #2
TS
Thanks for your prompt response.
To answer you, let's say the field "fruit" has 3 values (apple, orange,
grape), and I have 3 check boxes for each one of them. I want the user when
selecting the check box for "grape" and hit the save button, the word "grape"
gets saved in the database. Now, as you mention I can use a loop to check the
checked propety for the check boxes and puch to a database a value based on
the user's selection, but how to loop through the checkboxes included in the
groupbox? And how the word "grape" in the database will be translated to (a
check box that is checked) when users view the data in their windows form.
--
TS
"Jim Underwood" wrote:
TS,
I believe the answer you got for the first post was no, this cannot be done
as you describe it.

You probably need to manually assign a value to each checkbox. Associating
specific database vales to each checkbox when loading/saving data would also
have to be done manually, probably by looping through the check boxes and
checking each one as you load/save data. This isn't too bad if you know in
advance what checkboxes you want to display.

If you want to add checkboxes based on data, this can be done
programmatically, but I am not the one to explain how to do it. For
example, you have a field "fruit" in the database with 3 values (apple,
orange, grape), and you want 3 checkboxes. Someone adds a value (peach) to
the database, now you want the app to display 4 checkboxes. Is this what
you are trying to do?

AFAIK means As Far As I Know.
"TS" <TS@discussions.microsoft.com> wrote in message
news:08**********************************@microsof t.com...
Hi everybody,
I posted this question before but got a strange response from someone.
Anyways, is it possible to bind a GroupBox that includes multiple check
boxes to a column in a SQL database? Yes or No.

If it's yes, when the user checks one of these check boxes, what value

will
be stored in the column? I'm really confused about that. Please help.
If there is any white paper about this, it will also be helpful.
--
TS


Nov 23 '05 #3
use events instead. Have a variable that is strFruit. If you have a set
amount you can even use enums to make it easier

public enum FruitType
"Banana"
"Cherry"
"Peach"

private mFruit as fruitType
Public Property Fruit as FruitType
....
....

....

then in the checkchanged event have the handler change the value of the
variable. Then pass the variable to your dataprovider and write the value to
your database.
--
--Eric Cathell, MCSA
"TS" <TS@discussions.microsoft.com> wrote in message
news:DF**********************************@microsof t.com...
Thanks for your prompt response.
To answer you, let's say the field "fruit" has 3 values (apple, orange,
grape), and I have 3 check boxes for each one of them. I want the user
when
selecting the check box for "grape" and hit the save button, the word
"grape"
gets saved in the database. Now, as you mention I can use a loop to check
the
checked propety for the check boxes and puch to a database a value based
on
the user's selection, but how to loop through the checkboxes included in
the
groupbox? And how the word "grape" in the database will be translated to
(a
check box that is checked) when users view the data in their windows form.
--
TS
"Jim Underwood" wrote:
TS,
I believe the answer you got for the first post was no, this cannot be
done
as you describe it.

You probably need to manually assign a value to each checkbox.
Associating
specific database vales to each checkbox when loading/saving data would
also
have to be done manually, probably by looping through the check boxes and
checking each one as you load/save data. This isn't too bad if you know
in
advance what checkboxes you want to display.

If you want to add checkboxes based on data, this can be done
programmatically, but I am not the one to explain how to do it. For
example, you have a field "fruit" in the database with 3 values (apple,
orange, grape), and you want 3 checkboxes. Someone adds a value (peach)
to
the database, now you want the app to display 4 checkboxes. Is this what
you are trying to do?

AFAIK means As Far As I Know.
"TS" <TS@discussions.microsoft.com> wrote in message
news:08**********************************@microsof t.com...
> Hi everybody,
> I posted this question before but got a strange response from someone.
> Anyways, is it possible to bind a GroupBox that includes multiple check
> boxes to a column in a SQL database? Yes or No.
>
> If it's yes, when the user checks one of these check boxes, what value

will
> be stored in the column? I'm really confused about that. Please help.
> If there is any white paper about this, it will also be helpful.
> --
> TS


Nov 23 '05 #4
Create a group box and put 3 checkboxes inside it, then add this code to
your project. This will loop through all the objects inside the group box.
When loading from or saving to the database, use the .text property of the
checkbox to determine whether or not it should be checked, or what value
should be returned when it is checked.

Private Sub testgroupbox()
Dim mycontrol As Windows.Forms.Control
Dim myCheckbox As New Windows.Forms.CheckBox
For Each mycontrol In GroupBox1.Controls
If mycontrol.GetType Is myCheckbox.GetType Then
myCheckbox = mycontrol
MsgBox(myCheckbox.Name & " = " & myCheckbox.Text)
End If
Next
End Sub

"TS" <TS@discussions.microsoft.com> wrote in message
news:DF**********************************@microsof t.com...
Thanks for your prompt response.
To answer you, let's say the field "fruit" has 3 values (apple, orange,
grape), and I have 3 check boxes for each one of them. I want the user when selecting the check box for "grape" and hit the save button, the word "grape" gets saved in the database. Now, as you mention I can use a loop to check the checked propety for the check boxes and puch to a database a value based on the user's selection, but how to loop through the checkboxes included in the groupbox? And how the word "grape" in the database will be translated to (a check box that is checked) when users view the data in their windows form.
--
TS
"Jim Underwood" wrote:
TS,
I believe the answer you got for the first post was no, this cannot be done as you describe it.

You probably need to manually assign a value to each checkbox. Associating specific database vales to each checkbox when loading/saving data would also have to be done manually, probably by looping through the check boxes and checking each one as you load/save data. This isn't too bad if you know in advance what checkboxes you want to display.

If you want to add checkboxes based on data, this can be done
programmatically, but I am not the one to explain how to do it. For
example, you have a field "fruit" in the database with 3 values (apple,
orange, grape), and you want 3 checkboxes. Someone adds a value (peach) to the database, now you want the app to display 4 checkboxes. Is this what you are trying to do?

AFAIK means As Far As I Know.
"TS" <TS@discussions.microsoft.com> wrote in message
news:08**********************************@microsof t.com...
Hi everybody,
I posted this question before but got a strange response from someone.
Anyways, is it possible to bind a GroupBox that includes multiple check boxes to a column in a SQL database? Yes or No.

If it's yes, when the user checks one of these check boxes, what value

will
be stored in the column? I'm really confused about that. Please help.
If there is any white paper about this, it will also be helpful.
--
TS


Nov 23 '05 #5
YYZ
> To answer you, let's say the field "fruit" has 3 values (apple, orange,
grape), and I have 3 check boxes for each one of them.


Do you really want checkboxes? How about Radio Buttons instead. If
the user can only choose one of the 3, then radio buttons is what you
should use. If they can choose 0 or more then you should use
checkboxes.

If you DO need checkboxes, because they can choose grape and orange at
the same time, then you need fields in the DB for each fruit type -- or
a separate table with a fruit description and a value to indicate yes,
the user chose it, or no, they didn't choose it.

See what I mean?

If you do that, then I think your binding issue will kind of take care
of itself. However, I'm ultra-new to .Net, and in VB6 I never bound
anything, so don't listen to me on that topic. But what I said about
checkboxes vs. radio buttons still holds up, though...

Matt

Nov 23 '05 #6

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

2
by: Job Lot | last post by:
I have 2 group box Buy and Sell on a form. There is an account combo box in both group boxes bound to same data source using DataSource, DisplayMember and ValueMember. Problem is binding context is...
1
by: Savvas | last post by:
Dear Cor Ligthert My account is not yet validated so i cannot log in to reply directly to you. An analogy of what i need is the following: Say e.g. you have a groub box "Sex" and two radio...
0
by: Savvas | last post by:
Hi all I still havent managed to bind the radio buttons. I have two radio buttons in a groupbox. Adding a record and choosing either one of the two i have no problem - the correct boolean value...
0
by: Mark Johnson | last post by:
Sometimes Controls that have been added to a GroupBox do not show up. What I am doing : 1) I am not using the designer, but create all the Controls per hand: groupBoxProdukt_01 = new...
0
by: Uchiha Jax | last post by:
When using a strongly typed dataset (generated from the Visual Studio IDE from an XSD file) and databinding I get a really odd error when binding to both a combox and a datetimepicker. I bind...
4
by: TJS | last post by:
I get this error at time of compiling my class code what's missing ?? =================== error ============================= Me.groupBox1 = New GroupBox ~~~~~~~~~~~~~ C:\Documents and...
8
by: johnmmcparland | last post by:
Hi all, my program is trying to add group boxes with radio buttons at run time. While at one point it was able to draw the group boxes without the radio buttons, now it encounters problems just...
0
by: A.J | last post by:
There is a : 1.DataGrid: Columns-->firstName,LastName,EMail,PhoneNumber 2.GroupBox: controls-->4 TextBoxes(firstName,LastName,EMail,PhoneNumber) 3.Both DataGrid and GroupBox are binded to the...
8
by: Steve | last post by:
Hi All Is there a way to change the colour of a Groupbox border in VB.net 2005 I want to change it to white Can it be done in the onpaint event? Regards Steve
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
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
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,...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...
0
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...

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.