Solved

Programmatically selected a TButtonItem in a TCategoryButton.

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

Networking for the Cloud Era

Join Microsoft and Riverbed for a discussion and demonstration of enhancements to SteelConnect:
-One-click orchestration and cloud connectivity in Azure environments
-Tight integration of SD-WAN and WAN optimization capabilities
-Scalability and resiliency equal to a data center

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
error when i compile 5 725
VB.Net Reusable Form Layout 4 160
Android studio getdrawable(int) is deprecated 4 123
JavaFX TableView not displaying correctly 3 63
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…
How to install Selenium IDE and loops for quick automated testing. Get Selenium IDE from http://seleniumhq.org Go to that link and select download selenium in the right hand columnThat will then direct you to their download page.From that page s…
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.

821 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