8 Replies - 1177 Views - Last Post: 07 May 2013 - 01:36 PM Rate Topic: -----

#1 Pooja Mengaji  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 43
  • Joined: 24-February 13

how to Lock controls of the form?

Posted 07 May 2013 - 06:02 AM

i hav created a form with a button "View". wen the user clicks on view rest all controls placed on the form shud b locked...is it possible to do it in vb.net...shud the enabled property b used or is der any other way to do it?
Is This A Good Question/Topic? 0
  • +

Replies To: how to Lock controls of the form?

#2 modi123_1  Icon User is online

  • Suitor #2
  • member icon



Reputation: 9425
  • View blog
  • Posts: 35,421
  • Joined: 12-June 08

Re: how to Lock controls of the form?

Posted 07 May 2013 - 06:03 AM

The enabled property is what you want to use.
Was This Post Helpful? 0
  • +
  • -

#3 Luc001  Icon User is offline

  • D.I.C Addict

Reputation: 84
  • View blog
  • Posts: 617
  • Joined: 04-May 09

Re: how to Lock controls of the form?

Posted 07 May 2013 - 08:56 AM

Hi,

Like modi123_1 said you can use Enabled.
But it depends what you want, because you can make them visible also like:

Button.Visible=True or False.

Grtz,
Was This Post Helpful? 0
  • +
  • -

#4 Pooja Mengaji  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 43
  • Joined: 24-February 13

Re: how to Lock controls of the form?

Posted 07 May 2013 - 09:36 AM

View Postmodi123_1, on 07 May 2013 - 06:03 AM, said:

The enabled property is what you want to use.

k if i use enabled then
For Each cont As Control In Me.Controls
            If TypeOf cont Is GroupBox Then
             cont.Enabled=true
            Else
             cont.Enabled=False
            End If
        Next



i want controls placed in groupbox2 to be enabled to true...how do i refer it in for each loop in if condition...
Was This Post Helpful? 0
  • +
  • -

#5 andrewsw  Icon User is offline

  • It's just been revoked!
  • member icon

Reputation: 3642
  • View blog
  • Posts: 12,619
  • Joined: 12-December 12

Re: how to Lock controls of the form?

Posted 07 May 2013 - 09:43 AM

For Each cont As Control In GroupBox2.Controls

although, you should be renaming all your controls to something more useful.

This post has been edited by andrewsw: 07 May 2013 - 09:44 AM

Was This Post Helpful? 0
  • +
  • -

#6 Pooja Mengaji  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 43
  • Joined: 24-February 13

Re: how to Lock controls of the form?

Posted 07 May 2013 - 09:54 AM

View Postandrewsw, on 07 May 2013 - 09:43 AM, said:

For Each cont As Control In GroupBox2.Controls

although, you should be renaming all your controls to something more useful.

so the code shud be like this?
For Each cont As Control In Me.Controls
    For Each c As Control In GroupBox2.Controls
      c.Enabled=true
    Next
cont.Enabled=False 
Next



Was This Post Helpful? 0
  • +
  • -

#7 andrewsw  Icon User is offline

  • It's just been revoked!
  • member icon

Reputation: 3642
  • View blog
  • Posts: 12,619
  • Joined: 12-December 12

Re: how to Lock controls of the form?

Posted 07 May 2013 - 09:58 AM

View PostPooja Mengaji, on 07 May 2013 - 04:54 PM, said:

so the code shud be like this?
For Each cont As Control In Me.Controls
    For Each c As Control In GroupBox2.Controls
      c.Enabled=true
    Next
cont.Enabled=False 
Next



Please do not use text (kiddy)-speak, it is not appropriate for a forum.

If you want to enable or disable the controls inside the groupbox then you don't need to loop through every single control on the form (Me.Controls).
Was This Post Helpful? 0
  • +
  • -

#8 CharlieMay  Icon User is offline

  • This space intentionally left blank
  • member icon

Reputation: 1605
  • View blog
  • Posts: 5,162
  • Joined: 25-September 09

Re: how to Lock controls of the form?

Posted 07 May 2013 - 12:52 PM

For each c as control in me.controls
  c.enabled = false
next


This will disable every control on the form. However, the controls in the groupboxes arent actually disabled from this, they are disabled from the groupbox being disabled.

Therefore you could use the code above to disable all controls on the form and then just immediately use
GroupBox2.Enabled = True

after that code runs.

This will enable Groupbox2 thus enabling the controls that reside in its control collection.
Was This Post Helpful? 1
  • +
  • -

#9 AdamSpeight2008  Icon User is offline

  • MrCupOfT
  • member icon


Reputation: 2268
  • View blog
  • Posts: 9,482
  • Joined: 29-May 08

Re: how to Lock controls of the form?

Posted 07 May 2013 - 01:36 PM

Can't you disable the then Form?
Was This Post Helpful? 0
  • +
  • -

Page 1 of 1