Reputation: 375
Is it possible to in anyway display content in a windows form application based on how many rows there are in a database. I have no idea if this is possible in a simple way, but the concept is attached below which show the content section, the left side is an image and label2 should be the name for the person and label 3 is the content that the person writes.
Now the question is if there are more than one post, how can I make the "rows" show for all the content from a database. If I would have used ASP.NET it would probably be easier because the format would be:
<ul>
<li><img src="#"/> <h1>Name</h1> <p>Content<p> </li>
<ul>
Upvotes: 4
Views: 747
Reputation: 5314
What you're looking for is a ListView control. You will create a loop and add items for each row returned from the database. Check out Using a ListView with images for an example.
Edit: using a DataGridView will allow you to have multilines in each cell. Here's a quick example, I don't have a small image handy but this will set your text properly:
DataGridView dgv = new DataGridView();
dgv.Columns.Add("Header","Header");
dgv.Columns.Add("Details", "Details");
dgv.Dock = DockStyle.Fill;
dgv.Columns[1].DefaultCellStyle.WrapMode = DataGridViewTriState.True;
dgv.AutoSizeRowsMode = DataGridViewAutoSizeRowsMode.AllCells;
dgv.Rows.Add(new string[] { "Drew", "Some details" + Environment.NewLine + "use two lines" });
dgv.Rows.Add(new string[] { "Bill", "More details" });
Controls.Add(dgv);
Upvotes: 2
Reputation: 97
You should prepare a user control with your "post" look And next use FlowLayoutPanel as container and add to his Children your "Control" created for each post from db.
Edit: If you set FlowLayoutPanel.FlowDirection to TopDown you will get what you are looking for.
Upvotes: 4