Solved

Programmatically selected a TButtonItem in a TCategoryButton.

Posted on 2007-04-10
4
910 Views
Last Modified: 2013-12-14
Thanks to Experts Exchange, I have learned how to dyamically load a TCategoryButtons component
with categories and button items and display them on demand. Here is my logic:

(This information is in my header file!)
//button category
TButtonCategory **bcCategory;
//button items
TButtonItem **biAssignment;

iassignindex = 0;
for (icatindex = 0; icatindex < MainWindow->itotalcategories; icatindex++)
{
     //----------------------------------------------------------------
     //  add a category button...
     //----------------------------------------------------------------
     bcCategory[icatindex] = cbCatsAndAssignsPad->Categories->Add();

     //----------------------------------------------------------------
     //  load the category caption...
     //----------------------------------------------------------------
    bcCategory[icatindex]->Caption = MainWindow->category[icatindex].name;

     for (icount = 0; icount < MainWindow->category[icatindex].numberofassignments; icount++)
           {
      //----------------------------------------------------------------
      //  add an assignment button...
      //----------------------------------------------------------------
      biAssignment[icount] = bcCategory[icatindex]->Items->Add();

      //----------------------------------------------------------------
      //  load the assignment caption...
      //----------------------------------------------------------------
      biAssignment[icount]->Caption = MainWindow->assignment[iassignindex].name;

      iassignindex = iassignindex + 1;
          }
}

What I need to know is how do I programatically select a particular button item IN A CATEGORY
when the component is displayed?

The documentation is of no help!

Thanks!!

Product Name: Borland Developer Studio/C++ Builder 2006
Operating System: Windows XP
Error Messages: None
0
Comment
Question by:gentv
4 Comments
 
LVL 16

Accepted Solution

by:
George Tokas earned 25 total points
ID: 18927105
Better late than never...
I'm not currently work with bcb2006 but this is a general idea.
Since TButtonItem is descend from TButton then you can assign a value in the Tag property...
Also for all buttons you can assign a global OnMouseClick in example derived method to be processed when you are clicking any of these buttons...
Detecting the value of Tag property you can find out the button pressed.
I hope this is what you wanted.

George Tokas.
0
 
LVL 18

Assisted Solution

by:JoseParrot
JoseParrot earned 25 total points
ID: 18950993
Another approach is to use some TButtonItem property to do that.
As I have only BCB6 Personal, I don't have these components, but probably the Object Inspector in BCB Developer Studio 2006 shows Properties as the one you are looking for. Something similar to the ToolBar with two ToolButtons, where the ToolButton->Images Property has an index related to an ImageList with two bitmaps and such indexes can be modified programaticatly, as in:
void __fastcall TForm1::Button1Click(TObject *Sender)
{
    if (ToolButton2->ImageIndex==2)
    {
        ToolButton2->ImageIndex=1;
        ToolButton1->ImageIndex=2;
    }
    else
    {
        ToolButton1->ImageIndex=1;
        ToolButton2->ImageIndex=2;
    }
}
Jose
0

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Programmer's Notepad is, one of the best free text editing tools available, simply because the developers appear to have second-guessed every weird problem or issue a programmer is likely to run into. One of these problems is selecting and deleti…
Update (December 2011): Since this article was published, the things have changed for good for Android native developers. The Sequoyah Project (http://www.eclipse.org/sequoyah/) automates most of the tasks discussed in this article. You can even fin…
The viewer will learn how to synchronize PHP projects with a remote server in NetBeans IDE 8.0 for Windows.
The viewer will learn how to use and create new code templates in NetBeans IDE 8.0 for Windows.

920 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

14 Experts available now in Live!

Get 1:1 Help Now