如何在表单中加载listview。 [英] How to get the listview loaded in the form.

查看:102
本文介绍了如何在表单中加载listview。的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在我的项目中,我需要获取包含后端数据的listview,如果我将listview放在表单中,单击按钮我可以加载数据,但要求最初应该隐藏listview或不存在,仅在单击按钮时,应使用数据查看列表视图。谢谢。

In my project, I need to get the listview containing the data from the back end, If I place the listview in the form and upon clicking a button I can load data, but the requirement is initially the listview should be hidden or not present there, only on clicking the button the listview should be viewed with data. Thank you.

推荐答案

在设计时将ListView的Visible属性设置为False。



按钮点击事件使用以下内容使列表可见。

At design time set the ListView's Visible property to False.

On button click event use the below to make the list visible.
ListVW.Visible = true;


以下是代码示例:



Here's a example of the code:

public Form1()
        {
            InitializeComponent();
            //Set the listView Visible property to false
            listView1.Visible = false;
        }
        
        private void button1_Click(object sender, EventArgs e)
        {
            //Set the listView Visible property to true
            listView1.Visible = true;
            //Add data
            listView1.Items.Add("one");
        }


Set the List View's property Visible = Falsein the properity window.

Within the button click event handler set it to true;

listView1.Visible = true;


这篇关于如何在表单中加载listview。的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆