Board index » cppbuilder » Toolbar buttons

Toolbar buttons

I'm trying to access a series of toolbar buttons. The following throws up an
error. How may I do this correctly?

void __fastcall TForm1::Button1Click(TObject *Sender)
{
for(int Count = 1; Count <= 10; Count++)
Form1->ToolBar1->Button[Count]->Enabled = false;

Quote
}

--
Yours,

Slartibardfast & Zephod Beeblebrox
.......................................................
Try not to spam. Your server's admin
 might get annoyed.

 

Re:Toolbar buttons


Quote
> for(int Count = 1; Count <= 10; Count++)

Make sure that Count < ToolBar1->ButtonCount.  (Also, obviously,
starting at 1 excludes the first button.)

Quote
> Form1->ToolBar1->Button[Count]->Enabled = false;

That should be "Buttons".

The rest is OK and should work.  If not, precise what type of error is
thrown.

--
Yoto Yotov

Re:Toolbar buttons


Your loop is wrong, it's going out of range.  Try this instead:

void __fastcall TForm1::Button1Click(TObject *Sender)
{
    for(int Count = 0; Count < 10; Count++)
        Form1->ToolBar1->Buttons[Count]->Enabled = false;

Quote
}

Gambit

"Slartibardfast & Zephod Beeblebrox" <Rhys_Sage I think we need an "a" in a

Quote
circle, here yahoo.com> wrote in message news:3bbef52b_2@dnews...
> I'm trying to access a series of toolbar buttons. The following throws up
an
> error. How may I do this correctly?

Re:Toolbar buttons


Thanks Remy and Yoto,
    The missing s was the problem. The loop was an illustration of the kind
of thing I wanted to do. Thanks for the help guys.

--
Yours,

Slartibardfast & Zephod Beeblebrox
.......................................................
Try not to spam. Your server's admin
 might get annoyed.

Quote
Yoto Yotov <y...@NOSPAMgmx.fr> wrote in message

news:MPG.1628ce01115afc259896a8@newsgroups.borland.com...
Quote
> > for(int Count = 1; Count <= 10; Count++)

> Make sure that Count < ToolBar1->ButtonCount.  (Also, obviously,
> starting at 1 excludes the first button.)

> > Form1->ToolBar1->Button[Count]->Enabled = false;

> That should be "Buttons".

> The rest is OK and should work.  If not, precise what type of error is
> thrown.

> --
> Yoto Yotov

Other Threads