Set Accessory in run time

This is the forum for miscellaneous technical/programming questions.

Moderator: 2ffat

Set Accessory in run time

Postby Lena » Mon Nov 13, 2017 4:58 am

Hi.
How set Accessory in this code?
Code: Select all
std::unique_ptr<TIniFile> FileINI(new TIniFile(host));
std::unique_ptr<TStringList> ValueSection(new TStringList());
     FileINI->ReadSectionValues(L"CATEGORY", ValueSection.get());
     ListBox1->Items->BeginUpdate();
     try
      {

      for(int i = 0; i < ValueSection->Count; i++)
        {
         if(ValueSection->Names[i] != "")
          {
           ListBox1->Items->Add(ValueSection->ValueFromIndex[i]);
           TListBoxItem * item = static_cast<TListBoxItem*>(ListBox1->ItemByIndex(i));
           //then set font, heigth... for item
           if(item)
             {
              item->Height = 48;
              item->TextSettings->Font->Size = 24;
              item->TextSettings->Font->Style = TFontStyles() << fsBold;
              item->ItemData->Accessory = aMore; //error
                         //item->ItemData->Accessory = TAccessory::aMore;
             }

          }
        }
      }
      __finally
         {
         ListBox1->Items->EndUpdate();
         }


use of undeclared identifier 'aMore'
Last edited by Lena on Mon Nov 13, 2017 7:22 am, edited 2 times in total.
Lena
BCBJ Master
BCBJ Master
 
Posts: 520
Joined: Sun Feb 06, 2011 1:28 pm

Re: Set Accessory in run time

Postby Lena » Mon Nov 13, 2017 5:08 am

And the second question arose.
I see at breakpoints what this code does as it should. However, after starting the program, all items without these settings. Андроид 4.4.4
How to fix?
Code: Select all
if(item)
             {
              item->Height = 48;// I am here
              item->TextSettings->Font->Size = 24;
              item->TextSettings->Font->Style = TFontStyles() << fsBold;
item->Parent = ListBox1;
              //item->ItemData->Accessory = TListBoxAccessory() << aMore;
             }
Lena
BCBJ Master
BCBJ Master
 
Posts: 520
Joined: Sun Feb 06, 2011 1:28 pm

Re: Set Accessory in run time

Postby Lena » Mon Nov 13, 2017 7:47 am

I found:
item->ItemData->Accessory = TListBoxItemData::TAccessory::aNone;
But after start application in items NO
Height = 48
Font->Size = 24
fsBold
aMore

All items have only the standard views. :(

P.S. And such an option did not help.
Code: Select all
TListBoxItem * item = new TListBoxItem(ListBox1);
           //TListBoxItem * item = static_cast<TListBoxItem*>(ListBox1->ItemByIndex(i));
            if(item)
             {
              item->Height = 48;
              item->TextSettings->Font->Size = 24;
              item->TextSettings->Font->Style = TFontStyles() << fsBold;
              item->Parent = ListBox1;
              item->ItemData->Accessory = TListBoxItemData::TAccessory::aMore;
              item->Text =  ValueSection->ValueFromIndex[i];
              ListBox1->AddObject(item);
             }


or
Code: Select all
TListBoxItem * item = static_cast<TListBoxItem*>(ListBox1->ItemByIndex(i));
            if(item)
             {
              item->Height = 48;
              item->TextSettings->Font->Size = 24;
              item->TextSettings->Font->Style = TFontStyles() << fsBold;
              item->ItemData->Accessory = TListBoxItemData::TAccessory::aMore;
              item->StyledSettings = item->StyledSettings>>TStyledSetting::Other;
             }
Lena
BCBJ Master
BCBJ Master
 
Posts: 520
Joined: Sun Feb 06, 2011 1:28 pm

Re: Set Accessory in run time

Postby Lena » Mon Nov 13, 2017 8:56 am

Sorry I fix:
Code: Select all
std::unique_ptr<TIniFile> FileINI(new TIniFile(host));
std::unique_ptr<TStringList> ValueSection(new TStringList());
     FileINI->ReadSectionValues(L"CATEGORY", ValueSection.get());
     ListBox1->Items->BeginUpdate();
     try
      {
      for(int i = 0; i < ValueSection->Count; i++)
        {
         if(ValueSection->Names[i] != "")
          {
           ListBox1->Items->Add(ValueSection->ValueFromIndex[i]);
           TListBoxItem * item = static_cast<TListBoxItem*>(ListBox1->ItemByIndex(i));
            if(item)
             {
              item->Height = 48;
              item->TextSettings->Font->Size = 24;
              item->TextSettings->Font->Style = TFontStyles() << fsBold;
              item->ItemData->Accessory = TListBoxItemData::TAccessory::aMore;
              item->StyledSettings = item->StyledSettings>>TStyledSetting::Size;
              item->StyledSettings = item->StyledSettings>>TStyledSetting::Style;
             }

          }
        }
      }
      __finally
         {
         ListBox1->Items->EndUpdate();
         }
Lena
BCBJ Master
BCBJ Master
 
Posts: 520
Joined: Sun Feb 06, 2011 1:28 pm


Return to Technical

Who is online

Users browsing this forum: Baidu [Spider], Bing [Bot], Google [Bot] and 6 guests

cron