使用对象属性作为ListBox中的DisplayMember [英] Use a object property as the DisplayMember in ListBox

查看:563
本文介绍了使用对象属性作为ListBox中的DisplayMember的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想使用对象内部的对象的属性. 有没有办法做到这一点?

I want to use a property of an object that's inside an object. Is there a way to achieve this?

WebProxy proxy = new WebProxy("127.0.0.1:80");
ListBox listBox = new ListBox();
listBox.DisplayMember = **"Address.Authority"**; //Note: Address.Authority is an property inside the WebProxy object
listBox.Items.Add(proxy);

谢谢.

推荐答案

看看

Have a look at this question, it is essentially asking the same thing - the principle does not change between DataGridView and ListBox. Short answer: it's possible, but convoluted.

这篇关于使用对象属性作为ListBox中的DisplayMember的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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