Thread: TStringGrid component with TListBox inside

  1. #1
    Daniel Pertin
    Guest

    TStringGrid component with TListBox inside

    Hi all,

    I'm programming a component that is a derivate from TStringGrid. I want to put inside a TListBox component, so in each cell of the grid I'll be able to have multiple Items. (Well, in fact it isn't a TListBox rather than an own component derivated from it, but for the question, it should be enough with that infomration).

    I Associated the TListBox to the TStringGrid with:
    Code:
    TStringList1->Objects[x][y]=objListBox;
    I don't want to use scrolling inside each cell (it appears awfull), so when I add an Item in a TListBox inside a Cell, I grow up the Height of the TListBox, and the RowHeights[ARow].

    Well, I have override the DrawCell method of the TStringGrid, so I can draw the TListBox.

    Code:
    void __fastcall TBitmapStringGrid::DrawCell(int ACol, int ARow, const Types::TRect &ARect, TGridDrawState AState)
    {
        TListBox* objListBox = ( TListBox* )(Objects[ACol][ARow] );
    
        if (objListBox != NULL) //only if there are data
        {
          objListBox->Top  = ARect.Top;
          objListBox->Left = ARect.Left;
          objListBox->Height = ARect.Bottom - ARect.Top + 1;
          objListBox->Width  = ARect.Right - ARect.Left + 1;
          objListBox->Visible = True;
        }
        Canvas->Brush->Color=clWhite;
        Canvas->FillRect(ARect);
    }
    The problem is that when I scroll, it does extrange things. It overwrites the blank cells, and I'm unable to get that it scrolls correctly. The TlistBox component don't scroll when the TStrginGrid scroll.

    I Read in http://www.bridgespublishing.com/art...ds__part_I.htm
    that (obviously) it's a known issue of this, but I'm unable to find a solution.

    Help please!
    Regards,
    Daniel

  2. #2
    End Of Line Hammer's Avatar
    Join Date
    Apr 2002
    Posts
    6,231
    Thread moved to the Windows forum.
    When all else fails, read the instructions.
    If you're posting code, use code tags: [code] /* insert code here */ [/code]

  3. #3
    Daniel Pertin
    Guest
    Where're the Windows Forum? I thought that this was the windows programming forum :?

    Regards,
    Daniel

  4. #4
    End Of Line Hammer's Avatar
    Join Date
    Apr 2002
    Posts
    6,231
    Originally posted by Daniel Pertin
    Where're the Windows Forum? I thought that this was the windows programming forum :?

    Regards,
    Daniel
    The thread was originally in the C++ forum, I moved it to the Windows forum as it's a Windows specific question, that's all.
    When all else fails, read the instructions.
    If you're posting code, use code tags: [code] /* insert code here */ [/code]

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. call to realloc() inside a function: memory problem
    By simone.marras in forum C Programming
    Replies: 15
    Last Post: 11-30-2008, 10:01 AM
  2. STA component call MTA component
    By George2 in forum Windows Programming
    Replies: 0
    Last Post: 03-30-2008, 07:36 AM
  3. variables when declared inside or outside a function
    By jas_atwal in forum C Programming
    Replies: 6
    Last Post: 12-14-2007, 02:42 PM
  4. Still battling with Copy Control
    By Mario F. in forum C++ Programming
    Replies: 9
    Last Post: 06-23-2006, 08:04 AM
  5. Dikumud
    By maxorator in forum C++ Programming
    Replies: 1
    Last Post: 10-01-2005, 06:39 AM