473,320 Members | 1,861 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,320 software developers and data experts.

Greyed Out Checkbox

I need to be able to greyout one checkbox untill another is checked. I've tried using a split containter w/ two panels, and was able to hide the other text box. The trick was that if you checked the first the second would show, and you could check it. However, if you unchecked the first the second would hide but remain checked. If someone could point me in the right direction in regards to the type of method and event style it would be greatly appreciated.

Thanks,
M
Apr 26 '07 #1
2 8059
A little more clarification. I think I found what I was looking for.

Expand|Select|Wrap|Line Numbers
  1. Private Sub SplitContainer1_MouseEnter(ByVal sender As Object, ByVal e As System.EventArgs) Handles SplitContainer1.MouseEnter
  2.         Dim x As Boolean = CheckBox1.CheckState
  3.         If x = False Then
  4.             CheckBox2.Enabled = False
  5.         Else
  6.             CheckBox2.Enabled = True
  7.         End If
  8.     End Sub
But is it possible to activate this sub by default rather than by some event, as above.

Thanks,
M
Apr 26 '07 #2
Killer42
8,435 Expert 8TB
I think you're on the wrong track. You can hide or show the checkbox simply by setting its Visible property - no need to try and hide it behind something else, or show/hide the parent container.

From the sound of it, the event procedure which should be causing this to happen is the click event of the first checkbox.

Also, note that checkboxes have not two but three possible states. In VB6, which I'm familiar with, the possible values are:
  • 0 - Unchecked
  • 1 - Checked
  • 2 - Grayed
Presumably there are equivalent constants in VB.Net. Note that there are some implications of this - for example, a Boolean really isn't appropriate to store the information, since it can only represent two different states.

I'd also like to mention a couple of other points...
  • The .Enabled property doesn't affect the contents - just whether the user can interact with it.
  • This is a lot of unnecessary coding...
    Expand|Select|Wrap|Line Numbers
    1. If x = False Then
    2.   CheckBox2.Enabled = False
    3. Else
    4.   CheckBox2.Enabled = True
    5. End If
    You don't have to use boolean (True/False) values by testing them with something like an IF statement. You can simply transfer them directly like any other value. For example, the above snippet of code could be written in a single line
    Expand|Select|Wrap|Line Numbers
    1. CheckBox2.Enabled = x
Apr 26 '07 #3

Sign in to post your reply or Sign up for a free account.

Similar topics

4
by: Fred B | last post by:
I used VB about a month ago and I don't recall this being greyed out. How do I get it back? Thanks.
2
by: Michelle Collier-Moore | last post by:
Please could someone offer some advice regarding adding references to an Access database? I tried to open a project a few days ago sent to me by someone whose developer had left the company. I...
0
by: Pavs | last post by:
I have inherited a ms access database that i am meant to alter and make some changes to. The database was original i believe created in Access 2000 while now i am using Access 2002 and my OS is...
0
by: murdo[nospam] | last post by:
Hi, Have created a basic vbs test recorded through the browser which loads a single page but the following error occurs when it's started: Test 'XXXXX' could not start. (0x80041013). ACT...
4
by: magmo | last post by:
Hi I have created a windows form that hold a datagrid, that datagrid gets it values from a stored procedure. My problem is that I have added a checkbox to the datagrid and applied some style...
8
by: EdB | last post by:
In VB6, you could set a check box to checked, unchecked, or greyed. The latter would be used to show a setting but disable the control. In .Net, the third choice is not greyed, but...
2
by: NetRacer | last post by:
hi, i have a DataGrid with a DataGridBoolColumn. The assigned Column is a TinyInt and the values are only 0 or 1. I set these values to the TrueValue und FalseValue Property, but the CheckBox...
6
by: Ryan | last post by:
Is there any way to disable controls without causing them to be greyed out? Such as text boxes, list boxes, etc. Thanks. Ryan
14
by: TonyMacaroni | last post by:
Hi everyone, total newbie to all of this so please bear with me and help if you can! I'm creating a database for a charity using Access 2002 SP3, I have a form called "Member Data". Within the...
0
by: DolphinDB | last post by:
The formulas of 101 quantitative trading alphas used by WorldQuant were presented in the paper 101 Formulaic Alphas. However, some formulas are complex, leading to challenges in calculation. Take...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
0
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
0
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....

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.