我在winform添加一个datagridview,通过下列代码进行绑定。
Scroll选择为both
在窗体显示后,竖滚动条没有反映。水平滚动条可以作用。请问如何解决竖滚动条没有反映的问题?另外能否通过dataset来绑定dataGridView?
……
conn.Open();
SqlCommand comm = new SqlCommand();
comm.CommandText = "Select top 500 voicefile FROM GSMVoiceInfo WHERE (tPhone = '14444440') AND (LEN(VoiceFileName) > 0)";
comm.CommandTimeout = 300;
comm.Connection = conn; SqlDataReader dr;
dr = comm.ExecuteReader();
int i = 0;
while (dr.Read())
{
//i++;
this.dataGridView1.Rows.Add(new ListViewItem(dr.GetString(dr.GetOrdinal("voicefile "))));
}
conn.Close();
Scroll选择为both
在窗体显示后,竖滚动条没有反映。水平滚动条可以作用。请问如何解决竖滚动条没有反映的问题?另外能否通过dataset来绑定dataGridView?
……
conn.Open();
SqlCommand comm = new SqlCommand();
comm.CommandText = "Select top 500 voicefile FROM GSMVoiceInfo WHERE (tPhone = '14444440') AND (LEN(VoiceFileName) > 0)";
comm.CommandTimeout = 300;
comm.Connection = conn; SqlDataReader dr;
dr = comm.ExecuteReader();
int i = 0;
while (dr.Read())
{
//i++;
this.dataGridView1.Rows.Add(new ListViewItem(dr.GetString(dr.GetOrdinal("voicefile "))));
}
conn.Close();
另外可以通过dataset来绑定dataGridView
我的垂直滚动条出来了,但没有办法拉。。很奇怪啊.如何通过代码绑定dataset
我没有找到databind方法。
datamember=tablename