~Roxy's Blog~

Easy come,easy go~
listView中显示表格的方法例子(C#)
 private void ShowResultTest()
        
{
            lvSearchResult.Clear();

            
//设置listView的显示属性
            lvSearchResult.GridLines = false;
            lvSearchResult.FullRowSelect 
= true;
            lvSearchResult.View 
= View.Details;
            lvSearchResult.Scrollable 
= true;
            lvSearchResult.MultiSelect 
= false;
            lvSearchResult.HeaderStyle 
= ColumnHeaderStyle.Nonclickable;

            
// 针对数据库的字段名称,建立与之适应显示表头
            lvSearchResult.Columns.Add("用户呢称"150, HorizontalAlignment.Right);
            lvSearchResult.Columns.Add(
"移动电话"100, HorizontalAlignment.Left);
            lvSearchResult.Columns.Add(
"电子邮箱"150, HorizontalAlignment.Left);

            
//添加列表项
            for (int index = 0; index < 5; index++)
            
{
                ListViewItem item 
= new ListViewItem();
                item.SubItems.Clear();
                item.SubItems[
0].Text = "Name" + index.ToString();                
                item.SubItems.Add(
"Phone"+index.ToString());
                item.SubItems.Add(
"Email"+index.ToString());
                lvSearchResult.Items.Add(item);
                
            }
                        
        }

posted on 2007-04-29 10:47  Roxy_sy  阅读(640)  评论(0)    收藏  举报