[Solved] Hide control

Creating a macro - Writing a Script - Using the API (OpenOffice Basic, Python, BeanShell, JavaScript)
Post Reply
User avatar
kapbepucm
Posts: 9
Joined: Fri Feb 13, 2009 12:41 pm
Location: Latvia

[Solved] Hide control

Post by kapbepucm »

How to show/hide Control in Base form? For example, I want to hide the button.
Last edited by kapbepucm on Wed Mar 04, 2009 3:15 pm, edited 1 time in total.
OOo 3.0.X on Ms Windows XP + Ubuntu 8.10
Hardy
Volunteer
Posts: 103
Joined: Thu Jan 29, 2009 2:50 pm

Re: Hide control

Post by Hardy »

All controls I used so far have a boolean "Visible" property. You should need no more than setting that to True/False.
OOo 3.0.X on Ms Windows W2k
User avatar
kapbepucm
Posts: 9
Joined: Fri Feb 13, 2009 12:41 pm
Location: Latvia

Re: Hide control

Post by kapbepucm »

Code: Select all

Button2 = StarDesktop.CurrentComponent.DrawPage.Forms.GetByIndex(0).getByName("Button2")
button2.Visible=not button2.Visible
BASIC runtime error. Property or method not found.
Why?

PS: I use standard buttons in standard base form
OOo 3.0.X on Ms Windows XP + Ubuntu 8.10
Hardy
Volunteer
Posts: 103
Joined: Thu Jan 29, 2009 2:50 pm

Re: Hide control

Post by Hardy »

The quote of your code is too incomplete to tell. Guess: incomplete instantiation.
Well, you've expanded your post while I was typing.
I've used it in dialogs so far - would have to try in forms, before I can answer.
OOo 3.0.X on Ms Windows W2k
User avatar
kapbepucm
Posts: 9
Joined: Fri Feb 13, 2009 12:41 pm
Location: Latvia

Re: Hide control

Post by kapbepucm »

ok, full code:

Code: Select all

option explicit
global Button1 as object
global Button2 as object
global Button3 as object
global Button4 as object
global Button5 as object
Sub Main
  Button1 = StarDesktop.CurrentComponent.DrawPage.Forms.GetByIndex(0).getByName("Button1")
  Button2 = StarDesktop.CurrentComponent.DrawPage.Forms.GetByIndex(0).getByName("Button2")
  Button3 = StarDesktop.CurrentComponent.DrawPage.Forms.GetByIndex(0).getByName("Button3")
  Button4 = StarDesktop.CurrentComponent.DrawPage.Forms.GetByIndex(0).getByName("Button4")
  Button5 = StarDesktop.CurrentComponent.DrawPage.Forms.GetByIndex(0).getByName("Button5")
End Sub
sub Button1_OnClick()
  button2.Visible=not button2.Visible
end sub
sub "Button1_OnClick" run on click event of button1
Sub "Main" run on open document event of myform
incomplete instantiation
I have a standard installation
OOo 3.0.X on Ms Windows XP + Ubuntu 8.10
User avatar
kapbepucm
Posts: 9
Joined: Fri Feb 13, 2009 12:41 pm
Location: Latvia

Re: Hide control

Post by kapbepucm »

Problem solved.
tnk tohttp://www.oooforum.org/forum/viewtopic ... rol#256810

Code: Select all

dim button2 as object
Button2 = StarDesktop.CurrentComponent.DrawPage.Forms.GetByIndex(0).getByName("Button2")
thiscomponent.currentcontroller.getcontrol(button2).setVisible(False)
:D
OOo 3.0.X on Ms Windows XP + Ubuntu 8.10
User avatar
kapbepucm
Posts: 9
Joined: Fri Feb 13, 2009 12:41 pm
Location: Latvia

Re: [Solved] Hide control

Post by kapbepucm »

This code does not work correctly in 3.1.0. Why?
OOo 3.0.X on Ms Windows XP + Ubuntu 8.10
Post Reply