Solved

Programmatically selected a TButtonItem in a TCategoryButton.

Posted on 2007-04-10
4
908 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

Top 6 Sources for Identifying Threat Actor TTPs

Understanding your enemy is essential. These six sources will help you identify the most popular threat actor tactics, techniques, and procedures (TTPs).

Join & Write a Comment

Suggested Solutions

Title # Comments Views Activity
c++ class logger 6 103
importing  maven Project 5 231
maven import project error 7 122
error when i compile 5 492
In our object-oriented world the class is a minimal unit, a brick for constructing our applications. It is an abstraction and we know well how to use it. In well-designed software we are not usually interested in knowing how objects look in memory. …
How to install Selenium IDE and loops for quick automated testing. Get Selenium IDE from http://seleniumhq.org (http://seleniumhq.org) Go to that link and select download selenium in the right hand columnThat will then direct you to their downlo…
This tutorial covers a step-by-step guide to install VisualVM launcher in eclipse.
The viewer will learn how to synchronize PHP projects with a remote server in NetBeans IDE 8.0 for Windows.

758 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

22 Experts available now in Live!

Get 1:1 Help Now