using TlistVIew

This is a discussion on using TlistVIew within the C++ Programming forums, part of the General Programming Boards category; I am new to C++ programming at and currently i am using C++ builder... can you guys help me to ...

  1. #1
    Registered User
    Join Date
    Apr 2007
    Posts
    8

    using TlistVIew

    I am new to C++ programming at and currently i am
    using C++ builder...

    can you guys help me to create and format TListView dynamically.
    I will create and format it through code...

    the output would look something like this...

    Code:
    No.        Header1   Header2 ......  Header5
    1              1        2               5
    2              2        3               6  
    3
    :
    :
    10             10       11             14
    thnx guys...
    Last edited by ysabelle; 04-22-2007 at 05:53 AM.

  2. #2
    Its hard... But im here swgh's Avatar
    Join Date
    Apr 2005
    Location
    England
    Posts
    1,475
    Post an attempt first, then people can comment, make suggestions ect
    I'm just trying to be a better person - My Name Is Earl

  3. #3
    Registered User
    Join Date
    Apr 2007
    Posts
    8
    currently i am still trying to create it dynamically thru the code

    TListView* pListView;

    i have this statement both in the .cpp and the .h
    but i am encountering errors.

    please assist in helping me create it dynamically.
    help in builder is not showing how to dynamically
    create a TListView.

    thnx.

  4. #4
    Registered User
    Join Date
    Apr 2007
    Posts
    8
    I am trying to make a ListView dynamically.
    i patterned my code to what is given in the help file
    however when i execute the code, nothing is displayed
    on the form (blank form)
    what could be missing in my code... please help.

    Code:
    void __fastcall TForm1::FormCreate(TObject *Sender)
    
    {
      TListItem  *pListItem;
      TListColumn *pNewColumn;
      TListView *pListView;
      const char Names[6][2][10] =
       {{"Rubble","Barny"},
        {"Michael", "Johnson"},
        {"Bunny", "Bugs"},
        {"Silver", "HiHo"},
        {"Simpson", "Bart"},
        {"Squirrel", "Rocky"}};
    
      TListView   *pListView = new TListView(this);
      pListView->Parent = this;
      pListView->Align = alClient;
      pListView->ViewStyle = vsReport;
      pNewColumn = pListView->Columns->Add();
      pNewColumn->Caption = "Last";
    
      pNewColumn = pListView->Columns->Add();
      pNewColumn->Caption = "First";
      for (int i = 0; i < 6; i++)
      {
        pListItem = pListView->Items->Add();
        pListItem->Caption = Names[i][0];
        pListItem->SubItems->Add(Names[i][1]);
      }

  5. #5
    Registered User
    Join Date
    Apr 2007
    Posts
    8
    i fixed my problem with TListView...
    i am able to create it as well as format and write
    the column and row headers...

    now, how do i put the actual data....
    what propoerty of TListView do i need to use?
    is it Item ????

    if anyone can teach me the syntax.. it would be
    a great help...

    thnx in advance...

  6. #6
    and the hat of wrongness Salem's Avatar
    Join Date
    Aug 2001
    Location
    The edge of the known universe
    Posts
    32,500
    I imagine you go back to the manual, and find out what other methods there are besides Add()
    > pListItem = pListView->Items->Add();
    which implements the functionality you want.
    If you dance barefoot on the broken glass of undefined behaviour, you've got to expect the occasional cut.
    If at first you don't succeed, try writing your phone number on the exam paper.
    I support http://www.ukip.org/ as the first necessary step to a free Europe.

Popular pages Recent additions subscribe to a feed

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21