CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 4 of 4
  1. #1
    Join Date
    Apr 2008
    Posts
    4

    lsitview with autosize

    Hi! I've seen very few exampels on sizing the listview columns. While im adding file and dir paths to it, it automaticly gets cropped, which is kind of anoying. I dont know WHY ms diddnt included a option for length and dif length from row to row, but is there an easy way to solve this problem? I found one example in c++ and it diddnt make much sense to me.

    Any suggeston or help is very much appriciated.

    -pix

  2. #2
    Join Date
    May 2007
    Location
    Denmark
    Posts
    623

    Re: lsitview with autosize

    Just to be clear, you want the listview to automatically adjust its width to show a string in its entire length rather than showing a horizontal scrollbar?

    EDIT: Seems I confused the ListView with the ListBox ... well, it happens
    Last edited by foamy; April 28th, 2008 at 05:12 AM.
    It's not a bug, it's a feature!

  3. #3
    Join Date
    Feb 2008
    Posts
    61

    Post Re: lsitview with autosize

    Quote Originally Posted by cpix
    Hi! I've seen very few exampels on sizing the listview columns. While im adding file and dir paths to it, it automaticly gets cropped, which is kind of anoying. I dont know WHY ms diddnt included a option for length and dif length from row to row, but is there an easy way to solve this problem? I found one example in c++ and it diddnt make much sense to me.

    Any suggeston or help is very much appriciated.

    -pix

    You can always add a length to the column of a listview..
    Code:
    int colLength = 500;
    listview1.Columns.Add(L"Column Name", colLength);
    Last edited by somu0915; April 28th, 2008 at 08:18 AM.

  4. #4
    Join Date
    Apr 2008
    Posts
    4

    Re: lsitview with autosize

    seems i was bit unclear The problem im having is that I got a listview
    which is getting files and folder paths. Problem is, when i Drop a item to the listview the string gets cropped like this somefi~1.txt, it's not the listview that makes this problem, seems more like the drag from the folderview control (tested with others as well), so there must be some the way i retrive the data from the control im dragging from..

    private void ListView1_ItemDrag_1(object sender, System.Windows.Forms.ItemDragEventArgs e)
    {
    DoDragDrop(e.Item, DragDropEffects.Move);
    }

    private void ListView1_DragEnter_1(object sender,
    System.Windows.Forms.DragEventArgs e)
    {
    e.Effect = DragDropEffects.Copy;
    }

    and then finally:
    ===========
    FileName = ((string[])(e.Data.GetData("FileName")))[0];
    lbltest.Text = FileName;
    lvBackupFiles.Items.Add(FileName);
    =======

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