CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Page 2 of 2 FirstFirst 12
Results 16 to 23 of 23
  1. #16
    VictorN's Avatar
    VictorN is offline Super Moderator Power Poster
    Join Date
    Jan 2003
    Location
    Hanover Germany
    Posts
    20,430

    Re: Resize Row Height of CListCtrl

    Quote Originally Posted by seguprasad View Post
    it is creating multiline using Cwnd. But I have to use CFormView and over CFormView, I have to use CListCtrl.
    1. What is the problem to use *this* custom control on the FormView?
    2. Why do you "have to use" CListCtrl?

    Quote Originally Posted by seguprasad View Post
    Is ther any way to create multiline row in CListCtrl?
    I don't know!
    Try to search in the ListControl sections of www.codeproject.com and www.codeguru.com
    Victor Nijegorodov

  2. #17
    Join Date
    Apr 2000
    Location
    Belgium (Europe)
    Posts
    4,626

    Re: Resize Row Height of CListCtrl

    A CListCtrl does not provide a means to do what you ask (rows of variable height)

    A CListBox can do variable row heights, but it doesn't have a lot of support for columns, you can display columns, but they're typically not user-adjustable (no header control).

    A custom control like the one Victor linked is another possible alternative. The one he linked is one example, I'm sure there are other people that have made something similar as well, look around. Alternatively, you can write your own variety of a custom control that does exactly what you want.

    With a load of "tweaks" you can probably make a CListCtrl sort of do what you want, with a number of restrictions.
    1) Insert each row as an individual item and somehow maintain a "grouping" to know which individual rows make up a single logical item.
    2) Set the listcontrol to multi selection.
    3) When a row is selected, you also programmatically select all the other rows in the same grouping. When a row is deselected, you also programmatically deselect all the other rows in the same grouping.
    This approach will have a number of visual, aestetical and usability issues, but this may be acceptable to you.
    It's possible that for various reasons it won't work out. You're asking for doing something the CListCtrl wasn't designed for. Sometimes, you can work around that with varying degrees of success, and sometimes you can't.

  3. #18
    Join Date
    Jan 2008
    Location
    India
    Posts
    780

    Re: Resize Row Height of CListCtrl

    Hi all,

    i m increase the row height of ListCtrl with using of this code.

    Code:
    1.Change the style of list control to “owner draw fixed” style!
    
    2. m_RowList.ModifyStyle( LVS_OWNERDRAWFIXED, 0, 0 ); //in OnInitDialog
    
    3.
    void CDialogGuineaPig::OnMeasureItem(int nIDCtl, LPMEASUREITEMSTRUCT lpMeasureItemStruct)   
    {   
       // If this is our list control then increase height   
       if( nIDCtl == IDC_ROWLIST )   
       {   
          // Increase height by 10   
          lpMeasureItemStruct->itemHeight += 10;//10 is new row height   
       }   
    }
    #1 September 24th, 2010, 12:43 AM
    vjshankwar
    Member + Join Date: Jan 2008
    Location: India
    Posts: 676


    Row height of List Ctrl not change when Checkbox option used in List.

    --------------------------------------------------------------------------------

    Hi all,

    i m increase the row height of ListCtrl with using of this code.



    Code:
    1.Change the style of list control to “owner draw fixed” style!

    2. m_RowList.ModifyStyle( LVS_OWNERDRAWFIXED, 0, 0 ); //in OnInitDialog

    3.
    void CDialogGuineaPig::OnMeasureItem(int nIDCtl, LPMEASUREITEMSTRUCT lpMeasureItemStruct)
    {
    // If this is our list control then increase height
    if( nIDCtl == IDC_ROWLIST )
    {
    // Increase height by 10
    lpMeasureItemStruct->itemHeight += 10;//10 is new row height
    }
    }this is working fine but when i use CheckBox style in List ctrl its not working please tell me how can i increase List Row height with Checkbox.

    please tell me how can i do this.

    thanks in advance.
    IN A DAY, WHEN YOU DON'T COME ACROSS ANY PROBLEMS - YOU CAN BE SURE THAT YOU ARE TRAVELLING IN A WRONG PATH

  4. #19
    VictorN's Avatar
    VictorN is offline Super Moderator Power Poster
    Join Date
    Jan 2003
    Location
    Hanover Germany
    Posts
    20,430

    Re: Resize Row Height of CListCtrl

    Did you mean that the list control with LVS_EX_CHECKBOXES extended style didn't change the item height?
    Is the OnMeasureItem called in the case you "use CheckBox style in List ctrl"?
    Victor Nijegorodov

  5. #20
    Join Date
    Oct 2009
    Posts
    577

    Smile Re: Resize Row Height of CListCtrl

    Quote Originally Posted by VictorN View Post
    Did you mean that the list control with LVS_EX_CHECKBOXES extended style didn't change the item height?
    Is the OnMeasureItem called in the case you "use CheckBox style in List ctrl"?
    I would assume the list control has another ID and therefore the increase wasn't applied.

    The OnMeasureItem was called once for a list control. I did it myself a year ago and there is no way out.

    However the grouping suggested works quite fine if you can go without icons, checkboxes, automatic sort. I used a special background color for each second logical group and even achieved to place an edit control exactly above some multiple cells of a column in order to allow inline editing. Nevertheless the efforts were immense and if there is a custom multiline-listcontrol available I would go this way.

  6. #21
    Join Date
    May 2009
    Location
    Bengaluru, India
    Posts
    460

    Re: Resize Row Height of CListCtrl

    even ClistCtrl is derived from CWnd right? then why dont you use scope resolution operator :: and access base class methods...

  7. #22
    Join Date
    Apr 2000
    Location
    Belgium (Europe)
    Posts
    4,626

    Re: Resize Row Height of CListCtrl

    Unless i'm mistaken, LVS_EX_CHECKBOXES and ownerdraw can't be combined.

    So just for clarity sake and for all future reference.
    A CListControl (a.k.a. SysListControl32 common control) CANNOT create a list where each row determines it's own size. The 'FIXED' in the LVS_OWNERDRAWFIXED is further evidence that this is the case.
    You can make a CListCtrl owner draw and make the rows any height you want, but every row will have this same height.

    You can "fake" multiline by using multiple list rows and handling item selection to select a group of rows, but this will have a number of visual and usage limitation/issues which may or may not be acceptable to you.


    A CListBox CAN be made with rows of variable height. This is done by using the LBS_OWNERDRAWVARIABLE style (as opposed to LBS_OWERDRAWFIXED). Do NOT use the LBS_ styles on a CListCtrl, it won't work.
    A CListBox however doesn't have all the features of a listcontrol. Again, the different behaviour of a listbox may or may not be an issue to you.

    You can create your own type of control (or use one someone else has made) that mimics a CListCtrl as much as possible but allows multiline variable rows. Again, this may or may not have any number of isues.

    You may also be able to make something that works for you by using something else entirely like a RichEdit or a CHtmlEditCtrl. It won't work and behave like a listcontrol, but you may be able to get a result that achieves what you're after.

  8. #23
    Join Date
    Jan 2008
    Location
    India
    Posts
    780

    Re: Resize Row Height of CListCtrl

    Quote Originally Posted by VictorN View Post
    Did you mean that the list control with LVS_EX_CHECKBOXES extended style didn't change the item height?
    Is the OnMeasureItem called in the case you "use CheckBox style in List ctrl"?
    yes.
    IN A DAY, WHEN YOU DON'T COME ACROSS ANY PROBLEMS - YOU CAN BE SURE THAT YOU ARE TRAVELLING IN A WRONG PATH

Page 2 of 2 FirstFirst 12

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  





Click Here to Expand Forum to Full Width

Featured