日期:2014-05-18  浏览次数:20787 次

DataGridView数据源绑定字符数组问题--在线等!
我用数组作为DataGridView数据源的时候,它只显示数组里每项的长度...怎么不能样才能显示实际的字符串...
...这是代码...
string[] para = new string[] { "one", "two", "three" };
  this.dataGridView1.DataSource = para;

...显示结果...
.Length
 3
 3
 5

要怎样才能显示出
one
two
three

------解决方案--------------------
因為datasource綁的是對象屬性,所以建一個包含字符串的類,然後用對象數組是可以達到目的
public class TestView 

private String m_Test; 
public String Test 

get { return m_Test; } 
set { m_Test = value; } 

}
------解决方案--------------------
string[] test = new string[] { "one", "tow", "three" };
this.GridView1.DataSource = test;
this.GridView1.DataBind();

没有问题啊。显示的就是one,tow,three