this.dataGridView1.Refresh();对我不起作用? [英] this.dataGridView1.Refresh(); Doesn't work for me?

查看:400
本文介绍了this.dataGridView1.Refresh();对我不起作用?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个带有datagridview的WinForm ......每次按下一个按钮时,我都会有一个按钮列(更新,添加),行更新/添加。

i想要重新加载数据网格或者在从另一个表单添加或更新之后刷新它,以及在我有DGridview的同一个表单中...

i尝试

  .dataGridView1.Refresh(); 



但它不起作用



剩下的代码:



 尝试 
{

SqlConnection conn = new SqlConnection( Server = localhost; database = tailoringmng; integrated Security = true);
SqlCommand cmd = new SqlCommand( undonetask ,康涅狄格州);
cmd.CommandType = CommandType.StoredProcedure;
SqlDataAdapter da = new SqlDataAdapter(cmd);

if (conn == null && conn.State = = ConnectionState.Closed)
{
conn.Open();
}
dt = new DataTable( myTable的);
da.Fill(dt);

dgridstatus.DataSource = dt.DefaultView;

conn.Close();

解决方案

c-sharp-datagridview-refresh-after-insert [ ^ ]



插入后的DataGridView刷新 [ ^ ]



希望它会有所帮助..

i have a WinForm that has a datagridview ....there i have a button column every time a button is click dialogue box open for (update ,add )and rows are updated/added.
i want to reload the datagrid or refresh it after addition or updation from another form as well as in the same form where i have DGridview...
i tried

this.dataGridView1.Refresh();


but it doesn't work

my remaining Code:

try
              {

              SqlConnection conn = new SqlConnection("Server= localhost; database=tailoringmng; integrated Security=true");
              SqlCommand cmd = new SqlCommand("undonetask",conn);
              cmd.CommandType = CommandType.StoredProcedure;
              SqlDataAdapter da = new SqlDataAdapter(cmd);

              if (conn == null && conn.State == ConnectionState.Closed)
              {
                  conn.Open();
              }
             dt = new DataTable("myTable");
                  da.Fill(dt);

              dgridstatus.DataSource = dt.DefaultView;

              conn.Close();

解决方案

c-sharp-datagridview-refresh-after-insert[^]

DataGridView Refresh after insert[^]

Hope it will help..


这篇关于this.dataGridView1.Refresh();对我不起作用?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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