listbox绑定数据库
listbox和数据库绑定后输出的是
system.Data.DataRowView
system.Data.DataRowView
system.Data.DataRowView
system.Data.DataRowView
system.Data.DataRowView
system.Data.DataRowView
system.Data.DataRowView
system.Data.DataRowView
............
system.Data.DataRowView
代码如下
using System;
using System.Globalization;
using System.Collections.Generic;
using System.ComponentModel;
using System.Drawing;
using System.Data;
using System.Data.SqlClient;
using System.Text;
using System.Windows.Forms;
using System.IO;
using System.Net;
using System.Xml;
using System.Configuration;
using System.Collections;
private void button1_Click_1(object sender, EventArgs e)
{
string strConn = ConfigurationManager.ConnectionStrings["连接字符串"].ConnectionString;
SqlConnection myConn = new SqlConnection(strConn);
string strSQL = "select address from shuju ";
myConn.Open();
SqlCommand myCommand = new SqlCommand(strSQL, myConn);
SqlDataAdapter adapter = new SqlDataAdapter(myCommand);
DataSet ds = new DataSet();
adapter.Fill(ds, "address");
listBox1.DataSource = ds.Tables["address"];
myConn.Close();
}
这个该怎么改呢
------解决方案--------------------
设置listBox1.DisplayMember属性
listBox1.DisplayMember="address"