I'm a real dummy at UI building, so I'm wondering - what .NET winforms control would be best to use if aiming to display tweets in a list fashion that updates with like boxes which contain the text of the tweet and its metadata below it. Is there a specific winforms list function for this type of thing? Or do you recommend I look for/use a third party winforms control? Thanks! Hope my question wasn't too silly.
我是UI构建的真正假人,所以我想知道 - 如果旨在以列表方式显示推文,那么.NET winforms控件将最好用,其中包含包含推文文本及其元数据的类似框的更新在它下面。这种类型的东西是否有特定的winforms列表功能?或者你建议我寻找/使用第三方winforms控件?谢谢!希望我的问题不是太傻。
UPDATE: I am getting indication from numerous responses that it would be better to just build a simple winform control myself, but can anyone point me to a tutorial for doing so? Also, if i were to build such a control, does there exist a convenient built-in control for making like a list of custom controls that is scrollable - maybe Panel? Thanks in advance!
更新:我从众多回复中得到指示,我自己构建一个简单的winform控件会更好,但有人能指点我这样做的教程吗?另外,如果我要构建这样的控件,是否存在一个方便的内置控件,可以像可滚动的自定义控件列表一样 - 也许是Panel?提前致谢!
4 个解决方案
#1
I'd build a user control that would display the information for a single tweet. I'd then repeat that user control in a panel.
我将构建一个用户控件来显示单个推文的信息。然后我在面板中重复该用户控件。
You could just use the same layout in your user control that is standard for "tweets".
您可以在用户控件中使用相同的布局,这是“推文”的标准。
Left justified picture box to display the user image. LinkLabel for user name. Label for tweet text.
左对齐图片框显示用户图像。 LinkLabel用于用户名。推文文字的标签。
Update: Here are a couple pages on UserControls
更新:以下是UserControls的几页
http://msdn.microsoft.com/en-us/library/a6h7e207(VS.71).aspx
http://www.akadia.com/services/dotnet_user_controls.html
Create a usercontrol using the designer and also a Tweet class that is just a dumb data structure to hold each tweet's information. Also create a Tweet property on the custom user control that would handle setting the tweet and assigning information to the standard controls contained in it (Labels, Textboxs, PictureBox, etc).
使用设计器和Tweet类创建一个usercontrol,这只是一个愚蠢的数据结构来保存每条推文的信息。还要在自定义用户控件上创建一个Tweet属性,该属性将处理设置推文并将信息分配给其中包含的标准控件(标签,文本框,PictureBox等)。
In the form where you want to host your user control create a panel that is empty. Somewhere in your code you would do something similar to this code block.
在要托管用户控件的表单中,创建一个空的面板。在代码中的某处,您可以执行类似于此代码块的操作。
pnlHost.Controls.Clear();
List<Tweet> tweets = new List<Tweet>();
//Populate your collection of tweets here
foreach (Tweet tweet in tweets)
{
TweetControl control = new TweetControl();
control.Tweet = tweet;
pnlHost.Controls.Add(control);
control.Dock = DockStyle.Top;
}
#2
Hi I'd go for a third party grid control from companies like Infragistics, DevExpress or Telerik. Another option would be to build a usercontrol that is able to display one post and put that control into a vb.net repeater control (which ships with the vb.net powerpack). However I'm not sure how good the last solution actually works, as I just read about it, but never tried it.
嗨,我会从Infragistics,DevExpress或Telerik等公司寻求第三方网格控制。另一种选择是构建一个能够显示一个帖子并将该控件放入vb.net转发器控件(随vb.net powerpack一起提供)的用户控件。但是我不确定最后一个解决方案实际上有多好,因为我刚读过它,但从未尝试过。
#3
Try using DataGridView (and a DataTable behind it) and overwrite the CellPainting event to draw the tweets the way you like it.
尝试使用DataGridView(以及它背后的DataTable)并覆盖CellPainting事件,以您喜欢的方式绘制推文。
Edit I think using a custom control is a bit heavy just to display the tweets. Basically this depends on the desired functionality of the displayed tweets - what would you like to do with them. For example, if you just want the user to click the tweet and then redirect him to some webpage in the browser then the DataGridView
will do just fine since you can attach this action to the CellClick
event. Plus you already have the sorting/searching capabilities of the DataTable
(and the related DefaultView
)behind it. Hell, you can even attach a ContextMenuStrip
to the tweet and have unlimited options with the RightClick
.
编辑我认为使用自定义控件有点重,只是为了显示推文。基本上这取决于显示的推文所需的功能 - 你想用它们做什么。例如,如果您只是希望用户单击推文,然后将其重定向到浏览器中的某个网页,那么DataGridView就可以了,因为您可以将此操作附加到CellClick事件。此外,您已经拥有DataTable(以及相关的DefaultView)的排序/搜索功能。地狱,您甚至可以将ContextMenuStrip附加到推文上,并使用RightClick提供无限选项。
On the other hand if you need some functionality that is not available in the DataGridView
(for example, you would like 5 different buttons at the bottom of the tweet and 3 checkboxes on the right) then the custom control would do you better because you could build practically everything you wanted. In this case OG explains this nicely.
另一方面,如果您需要一些DataGridView中没有的功能(例如,您希望在推文底部有5个不同的按钮,右侧有3个复选框),那么自定义控件会让您更好,因为您可以几乎可以构建您想要的一切。在这种情况下,OG很好地解释了这一点。
#4
Try listbox, it's easy to use and seems like it will suit your needs.
尝试列表框,它易于使用,似乎它将满足您的需求。
#1
I'd build a user control that would display the information for a single tweet. I'd then repeat that user control in a panel.
我将构建一个用户控件来显示单个推文的信息。然后我在面板中重复该用户控件。
You could just use the same layout in your user control that is standard for "tweets".
您可以在用户控件中使用相同的布局,这是“推文”的标准。
Left justified picture box to display the user image. LinkLabel for user name. Label for tweet text.
左对齐图片框显示用户图像。 LinkLabel用于用户名。推文文字的标签。
Update: Here are a couple pages on UserControls
更新:以下是UserControls的几页
http://msdn.microsoft.com/en-us/library/a6h7e207(VS.71).aspx
http://www.akadia.com/services/dotnet_user_controls.html
Create a usercontrol using the designer and also a Tweet class that is just a dumb data structure to hold each tweet's information. Also create a Tweet property on the custom user control that would handle setting the tweet and assigning information to the standard controls contained in it (Labels, Textboxs, PictureBox, etc).
使用设计器和Tweet类创建一个usercontrol,这只是一个愚蠢的数据结构来保存每条推文的信息。还要在自定义用户控件上创建一个Tweet属性,该属性将处理设置推文并将信息分配给其中包含的标准控件(标签,文本框,PictureBox等)。
In the form where you want to host your user control create a panel that is empty. Somewhere in your code you would do something similar to this code block.
在要托管用户控件的表单中,创建一个空的面板。在代码中的某处,您可以执行类似于此代码块的操作。
pnlHost.Controls.Clear();
List<Tweet> tweets = new List<Tweet>();
//Populate your collection of tweets here
foreach (Tweet tweet in tweets)
{
TweetControl control = new TweetControl();
control.Tweet = tweet;
pnlHost.Controls.Add(control);
control.Dock = DockStyle.Top;
}
#2
Hi I'd go for a third party grid control from companies like Infragistics, DevExpress or Telerik. Another option would be to build a usercontrol that is able to display one post and put that control into a vb.net repeater control (which ships with the vb.net powerpack). However I'm not sure how good the last solution actually works, as I just read about it, but never tried it.
嗨,我会从Infragistics,DevExpress或Telerik等公司寻求第三方网格控制。另一种选择是构建一个能够显示一个帖子并将该控件放入vb.net转发器控件(随vb.net powerpack一起提供)的用户控件。但是我不确定最后一个解决方案实际上有多好,因为我刚读过它,但从未尝试过。
#3
Try using DataGridView (and a DataTable behind it) and overwrite the CellPainting event to draw the tweets the way you like it.
尝试使用DataGridView(以及它背后的DataTable)并覆盖CellPainting事件,以您喜欢的方式绘制推文。
Edit I think using a custom control is a bit heavy just to display the tweets. Basically this depends on the desired functionality of the displayed tweets - what would you like to do with them. For example, if you just want the user to click the tweet and then redirect him to some webpage in the browser then the DataGridView
will do just fine since you can attach this action to the CellClick
event. Plus you already have the sorting/searching capabilities of the DataTable
(and the related DefaultView
)behind it. Hell, you can even attach a ContextMenuStrip
to the tweet and have unlimited options with the RightClick
.
编辑我认为使用自定义控件有点重,只是为了显示推文。基本上这取决于显示的推文所需的功能 - 你想用它们做什么。例如,如果您只是希望用户单击推文,然后将其重定向到浏览器中的某个网页,那么DataGridView就可以了,因为您可以将此操作附加到CellClick事件。此外,您已经拥有DataTable(以及相关的DefaultView)的排序/搜索功能。地狱,您甚至可以将ContextMenuStrip附加到推文上,并使用RightClick提供无限选项。
On the other hand if you need some functionality that is not available in the DataGridView
(for example, you would like 5 different buttons at the bottom of the tweet and 3 checkboxes on the right) then the custom control would do you better because you could build practically everything you wanted. In this case OG explains this nicely.
另一方面,如果您需要一些DataGridView中没有的功能(例如,您希望在推文底部有5个不同的按钮,右侧有3个复选框),那么自定义控件会让您更好,因为您可以几乎可以构建您想要的一切。在这种情况下,OG很好地解释了这一点。
#4
Try listbox, it's easy to use and seems like it will suit your needs.
尝试列表框,它易于使用,似乎它将满足您的需求。