如何在datagridview中添加项目? [英] how to add items in datagridview?

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

问题描述



我有Windows应用程序。它包含1个网格视图1按钮(添加)和2个文本框。现在我在文本框中输入值,然后单击添加按钮,将值存储在网格视图中。

我的问题是在网格视图中添加值并关闭表单然后重新打开该表单,但将显示空的网格视图。我想先前添加这些项目。




i have windows application. it contains 1 grid view 1 button(Add ) and 2 textbox. now i enter the value in text-box and click the add button, the values stored in grid view.
My question is add the value in grid view and close the form then reopen that form but the empty grid view will displayed. i want to previously added the items.

private void button_Add_Click(object sender, EventArgs e)
       {
           
           dataGridView1.Rows.Add(textBox_Url.Text,textBox_Name.Text,textBox_password.Text);
           
           dataGridView1.Refresh();
       }

推荐答案

首先,DataGridView仅用于显示某些地方的数据。它不像你提到的那样存储在网格视图中的值。它不存储东西。如您所见,您可以将数据存储到例如数据库。



问候..
First of all,DataGridView is used just to display data from some where. Its not as you mentioned the values stored in grid view. Its not there to store something. As you can see the comment you can store data into e.g. database.

Regards..


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

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