7 Replies - 1184 Views - Last Post: 06 May 2012 - 03:37 PM Rate Topic: -----

#1 SplinteredChaos  Icon User is offline

  • D.I.C Head

Reputation: 11
  • View blog
  • Posts: 112
  • Joined: 15-September 11

Hide/Show items

Posted 05 May 2012 - 12:43 AM

I'm curious if it is possible to hide a group of text boxes from view in a form until a particular condition is met, and to have a custom set of text boxes for that condition. To give an example; I want radio buttons offering choices for a manner of searching records, the user selects one and then a specific set of text boxes are displayed for the user to utilize, if a different option is chosen a different set of text boxes will be shown. Is this something that can be done?
Is This A Good Question/Topic? 0
  • +

Replies To: Hide/Show items

#2 nK0de  Icon User is offline

  • Catch me As Exception
  • member icon

Reputation: 205
  • View blog
  • Posts: 823
  • Joined: 21-December 11

Re: Hide/Show items

Posted 05 May 2012 - 01:04 AM

Sure. Every control has a property called Visible. You can set it to True or False according to the the conditions.
Was This Post Helpful? 1
  • +
  • -

#3 digitaldevelopment  Icon User is offline

  • D.I.C Head

Reputation: 9
  • View blog
  • Posts: 168
  • Joined: 30-April 12

Re: Hide/Show items

Posted 05 May 2012 - 01:22 AM

snap wasn't first :( gonna answer it anyway ;)
let's assume you have a textbox called textbox1 (let's be original) and a radiobutton called radio1.
to make them invisible you do this:
textbox1.visible = False
radio1.visible = False


then to make then visible again
textbox1.visible = True
radio1.visible = True


Was This Post Helpful? 0
  • +
  • -

#4 polens  Icon User is offline

  • D.I.C Head

Reputation: 13
  • View blog
  • Posts: 155
  • Joined: 09-November 09

Re: Hide/Show items

Posted 05 May 2012 - 08:01 PM

or you can do it in a loop...
for each ctl as control in me.controls
if typeof ctl is textbox then
ctl.visible=false
end if

if type ctl is label then
ctl.visible=false
end if
'and so on
next

Was This Post Helpful? 0
  • +
  • -

#5 DimitriV  Icon User is offline

  • They don't think it be like it is, but it do
  • member icon

Reputation: 584
  • View blog
  • Posts: 2,738
  • Joined: 24-July 11

Re: Hide/Show items

Posted 05 May 2012 - 08:07 PM

That doesn't necessarily answer the question of a condition being met, though.
For Each Ctrl As Control In Me.Controls
If TypeOf Ctrl Is TextBox And showThem = True Then
CType(Ctrl,TextBox).Visible = True
Else
CType(Ctrl,TextBox).Visible = False


The reason I used CType was just so that I can see all of the members of the object that we are casting to. Without casting, all I see is
Equals
ReferenceEquals
ToString
Was This Post Helpful? 0
  • +
  • -

#6 Ionut  Icon User is offline

  • D.I.C Lover
  • member icon

Reputation: 385
  • View blog
  • Posts: 1,057
  • Joined: 17-July 10

Re: Hide/Show items

Posted 06 May 2012 - 12:18 AM

Quote

group of text boxes

put them in a panel or groupbox and hide that panel/groupbox using Visible property
Was This Post Helpful? 0
  • +
  • -

#7 ricardosms  Icon User is offline

  • D.I.C Regular
  • member icon

Reputation: 73
  • View blog
  • Posts: 301
  • Joined: 02-April 10

Re: Hide/Show items

Posted 06 May 2012 - 08:21 AM

You can use the "CheckedChanged" event for the RadioButton and change the textboxes' visible property to true or false accordingly.
Was This Post Helpful? 0
  • +
  • -

#8 SplinteredChaos  Icon User is offline

  • D.I.C Head

Reputation: 11
  • View blog
  • Posts: 112
  • Joined: 15-September 11

Re: Hide/Show items

Posted 06 May 2012 - 03:37 PM

Wow, thank you guys so much for the responses!
Was This Post Helpful? 0
  • +
  • -

Page 1 of 1