这是我的功能,但是我可以弄清楚如何在列表框中专门显示项目标题。
private void button1_Click(object sender, EventArgs e)
{
using (ClientContext ctx = new ClientContext("myurl"))
{
ctx.Credentials = CredentialsFactory.SharePointCredentials.CreateCredentials(txtUsername.Text, txtPassword.Text, CredentialsFactory.SharePointCredentials.SharePointAuthentication.SharePointOnline);
List clinicsList = ctx.Web.Lists.GetByTitle("Clinics");
CamlQuery query = CamlQuery.CreateAllItemsQuery(1000);
ListItemCollection clinics = clinicsList.GetItems(query);
ctx.Load(clinics);
ctx.ExecuteQuery();
listBox1.DataSource = clinics.ToList();
}
}
我确定这真的很简单!预先感谢!
这是输出的屏幕截图。
答案 0 :(得分:0)
您需要ListItem
中的ListItemCollection
// Show item in text box
ListItemCollection clinics = clinicsList.GetItems(query);
foreach (ListItem item in clinics)
{
ListBox1.Items.Add(item.Title);
}
希望这对您有帮助