listview problem - simple problem

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • newbie001

    #1

    listview problem - simple problem

    I have the following code in a listview control's
    initList function (called from form_load event). i can't
    understand why the listview box still appears blank with
    no columns or listview items.

    all help is appreciated.

    public void initList()
    {
    listView1.Enabl ed = true;
    listView1.View = View.Details;
    listView1.Check Boxes = true;
    listView1.FullR owSelect = true;

    ColumnHeader Col1 = new
    ColumnHeader();
    Col1.Text = "TestColA";
    Col1.Width = 1000;

    ColumnHeader Col2 = new
    ColumnHeader();
    Col2.Text = "TestColB";
    Col2.Width = 1000;

    ListViewItem lvwItem = new
    ListViewItem();
    listView1.Sorti ng =
    SortOrder.Ascen ding;

    // adding heading columns
    listView1.Colum ns.Clear();
    listView1.Colum ns.Add(Col1);
    listView1.Colum ns.Add(Col2);

    lvwItem.Text = "ABC";
    listView1.Items .Add(lvwItem);
    listView1.Items[0].SubItems.Add
    ("Test1");

    lvwItem = new ListViewItem();
    lvwItem.Text = "DEF";
    listView1.Items .Add(lvwItem);
    listView1.Items[0].SubItems.Add
    ("Test2");
    }
  • Mittal Ekta

    #2
    RE: listview problem - simple problem

    Hello newbie001,
    I tried your code and it works. Please confirm if you are still having
    problem with your code.

    Thanks,
    Mittal
    --------------------[color=blue]
    >Content-Class: urn:content-classes:message
    >From: "newbie001" <raptor@eminem. com>
    >Sender: "newbie001" <raptor@eminem. com>
    >Subject: listview problem - simple problem
    >Date: Tue, 30 Sep 2003 08:50:18 -0700
    >Lines: 45
    >Message-ID: <1e2a01c3876a$8 beb4280$a401280 a@phx.gbl>
    >MIME-Version: 1.0
    >Content-Type: text/plain;
    > charset="iso-8859-1"
    >Content-Transfer-Encoding: 7bit
    >X-Newsreader: Microsoft CDO for Windows 2000
    >X-MimeOLE: Produced By Microsoft MimeOLE V5.50.4910.0300
    >Thread-Index: AcOHaovrCWsdGqO ST9+QA1wYI6K5Zg ==
    >Newsgroups: microsoft.publi c.dotnet.langua ges.csharp
    >Path: cpmsftngxa06.ph x.gbl
    >Xref: cpmsftngxa06.ph x.gbl microsoft.publi c.dotnet.langua ges.csharp:1882 30
    >NNTP-Posting-Host: TK2MSFTNGXA12 10.40.1.164
    >X-Tomcat-NG: microsoft.publi c.dotnet.langua ges.csharp
    >
    >I have the following code in a listview control's
    >initList function (called from form_load event). i can't
    >understand why the listview box still appears blank with
    >no columns or listview items.
    >
    >all help is appreciated.
    >
    > public void initList()
    > {
    > listView1.Enabl ed = true;
    > listView1.View = View.Details;
    > listView1.Check Boxes = true;
    > listView1.FullR owSelect = true;
    >
    > ColumnHeader Col1 = new
    >ColumnHeader() ;
    > Col1.Text = "TestColA";
    > Col1.Width = 1000;
    >
    > ColumnHeader Col2 = new
    >ColumnHeader() ;
    > Col2.Text = "TestColB";
    > Col2.Width = 1000;
    >
    > ListViewItem lvwItem = new
    >ListViewItem() ;
    > listView1.Sorti ng =
    >SortOrder.Asce nding;
    >
    > // adding heading columns
    > listView1.Colum ns.Clear();
    > listView1.Colum ns.Add(Col1);
    > listView1.Colum ns.Add(Col2);
    >
    > lvwItem.Text = "ABC";
    > listView1.Items .Add(lvwItem);
    > listView1.Items[0].SubItems.Add
    >("Test1");
    >
    > lvwItem = new ListViewItem();
    > lvwItem.Text = "DEF";
    > listView1.Items .Add(lvwItem);
    > listView1.Items[0].SubItems.Add
    >("Test2");
    > }
    >[/color]

    --
    This posting is provided "AS IS" with no warranties, and confers no rights.
    Use of included script samples are subject to the terms specified at
    http://www.microsoft.com/info/cpyright.htm

    Comment

    Working...