Solved

Programmatically selected a TButtonItem in a TCategoryButton.

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

Free Tool: IP Lookup

Get more info about an IP address or domain name, such as organization, abuse contacts and geolocation.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

Jaspersoft Studio is a plugin for Eclipse that lets you create reports from a datasource.  In this article, we'll go over creating a report from a default template and setting up a datasource that connects to your database.
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…
The viewer will learn how to use NetBeans IDE 8.0 for Windows to connect to a MySQL database. Open Services Panel: Create a new connection using New Connection Wizard: Create a test database called eetutorial: Create a new test tabel called ee…
The viewer will learn how to use and create keystrokes in Netbeans IDE 8.0 for Windows.

739 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