views:

566

answers:

4

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.

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!

+1  A: 

Try listbox, it's easy to use and seems like it will suit your needs.

kkaploon
With a ListBox you have no control over what the items look like... unless you draw them manually with DrawMode = OwnerDrawVariable, which can be a PITA
Thomas Levesque
+2  A: 

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.

Andre Kraemer
DevExpress datagrid is quite fast and customisable.
jmservera
+2  A: 

Try using DataGridView (and a DataTable behind it) and overwrite the CellPainting event to draw the tweets the way you like it.

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.

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.

Ezekiel Rage
Will try. Thanks a bunch!
Maxim Zaslavsky
Here is a link to the MSDN article about the event and some nice sample code:http://msdn.microsoft.com/en-us/library/system.windows.forms.datagridview.cellpainting.aspx
Ezekiel Rage
+4  A: 

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.


Update: Here are a couple pages on 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).

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;

        }
OG
can you point me to a tutorial on building user controls? i think i get how to structure it, but saving it as a control and putting it into a panel is not in my current frame of knowledge. Thanks!
Maxim Zaslavsky
Rather than using the Dock property of the UserControl, I would use a FlowLayoutPanel...
Thomas Levesque