locked
dynamically increase listview row height in c# winforms RRS feed

  • Question

  • Hi,

    i want to listview row item increase and decrease dynamically..

    Example: in listview this below items are added in form load..

    Apple
    Anaconda
    Ball
    Bat
    Bomb
    Orange
    Billa

    if i search listview item in textbox  like  'A' two item only shown in listview so the listview row item decrease and if i search 'B' item four item shown in listview  increase the height of listview... how can i do this...is this possible to dynamically increase and decrease the listview row height ...??

    help this ..


    Mankatha

    Wednesday, April 11, 2012 12:44 PM

Answers

  • IIRC you cannot change height of rows - no property to do that. However, if you change the font size that will affect number of rows displayed. So you could try setting font size so it depends on number of item - more item smaller the font; few items large font.

    Alternatively, you could change the size of the listview but that could mess up the form.

    I'm not sure I'm right so someone else might suggests a better solution.


    Regards David R
    ---------------------------------------------------------------
    The great thing about Object Oriented code is that it can make small, simple problems look like large, complex ones.
    Object-oriented programming offers a sustainable way to write spaghetti code. - Paul Graham.
    Every program eventually becomes rococo, and then rubble. - Alan Perlis
    The only valid measurement of code quality: WTFs/minute.

    Wednesday, April 11, 2012 5:37 PM

All replies

  • You mean something like:

    you have  fixed height of a listview (like 200px). If there are 10 items in listview, each item`s row should be 20px height. If you do the filtering on 2 items only, each row shoud be 100px.

    Is that what you want?


    Mitja

    Wednesday, April 11, 2012 12:51 PM
  • ya like that...how can do that

    Mankatha


    • Edited by Mankatha da Wednesday, April 11, 2012 1:05 PM
    Wednesday, April 11, 2012 12:56 PM
  • IIRC you cannot change height of rows - no property to do that. However, if you change the font size that will affect number of rows displayed. So you could try setting font size so it depends on number of item - more item smaller the font; few items large font.

    Alternatively, you could change the size of the listview but that could mess up the form.

    I'm not sure I'm right so someone else might suggests a better solution.


    Regards David R
    ---------------------------------------------------------------
    The great thing about Object Oriented code is that it can make small, simple problems look like large, complex ones.
    Object-oriented programming offers a sustainable way to write spaghetti code. - Paul Graham.
    Every program eventually becomes rococo, and then rubble. - Alan Perlis
    The only valid measurement of code quality: WTFs/minute.

    Wednesday, April 11, 2012 5:37 PM
  • As Rised explained, no property that can do that. So I would go for dataGridView control, which is way better. You can set everything you wish actually.

    Mitja

    Wednesday, April 11, 2012 5:44 PM
  • ya mitja... and thnk u riced..

    Mankatha


    • Edited by Mankatha da Thursday, April 12, 2012 3:33 AM
    Thursday, April 12, 2012 3:29 AM