Solved

Programmatically selected a TButtonItem in a TCategoryButton.

Posted on 2007-04-10
4
931 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
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:Jose Parrot
Jose Parrot 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

Enroll in June's Course of the Month

June's Course of the Month is now available! Every 10 seconds, a consumer gets hit with ransomware. Refresh your knowledge of ransomware best practices by enrolling in this month's complimentary course for Premium Members, Team Accounts, and Qualified Experts.

Question has a verified solution.

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

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…
Here is a helpful source code for C++ Builder programmers that allows you to manage and manipulate HTML content from C++ code, while also handling HTML events like onclick, onmouseover, ... Some objects defined and used in this source include: …
This tutorial covers a step-by-step guide to install VisualVM launcher in eclipse.
THe viewer will learn how to use NetBeans IDE 8.0 for Windows to perform CRUD operations on a MySql database.

717 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