views:

943

answers:

4

I am trying to build an employee data entry form that looks like this:

Employee Form
-----------------------------------------------
---------------------------------------       |
|           |  Name       |           |       |
|  Picture  |  Department |           |       |
|           |  Position   |           |       |
|           |  DOB        |           |       |
---------------------------------------       |
... repeat for every employee                 |
...                                           |
---------------------------------------       |
|           |  Name       |           |       |
|  Picture  |  Department |           |       |
|           |  Position   |           |       |
|           |  DOB        |           |       |
---------------------------------------       |
-----------------------------------------------

It's very easy to build this with Microsoft Access, but how can I build it using Winforms + C# + .NET 3.5?
I tried to use DataGridView, but I could not make it look like my example above.

A: 

Why don't you try binding your data to a Repeater like so?

<asp:Repeater ID="Repeater1" runat="server">
    <HeaderTemplate>
        <table>
    </HeaderTemplate>
    <ItemTemplate>
        <tr>
            <td rowspan="4">
                <%# Eval("Picture") %>
            </td>
            <td>
                <%# Eval("Name") %>
            </td>
        </tr>
        <tr>
            <td>
                <%# Eval("Department") %>
            </td>
        </tr>
        <tr>
            <td>
                <%# Eval("Position") %>
            </td>
        </tr>
        <tr>
            <td>
                <%# Eval("DOB") %>
            </td>
        </tr>
    </tr>
</ItemTemplate>
<FooterTemplate>
    </table></FooterTemplate>
</asp:Repeater>
Ian Roke
Great for WebForms. Not so useful for WinForms.
Joseph Daigle
OK my bad I didn't read it closely enough.
Ian Roke
Thanks, I am using Microsoft Visual Basic Power Packs 3.0 which comes with DataRepeater. I am stuck with how to enumerate the elements inside the repeater. Why can't Microsoft provide easy access to the DataRepeater children?
portoalet
A: 

Try building a custom control which contains all the data for a single employee then adding multiple instances of that control to a FlowLayoutPanel or something similar. Your custom control could be simple with just a split panel containing a PictureBox and some TextBoxes.

SpaceghostAli
+1  A: 
Bryan
A: 

First, get BindingListView. Then, rather than using DataTables/Sets, you can bind List<T>s to DataGridViews. You can then set the DataPropertyName of the second column to a "Details" property like this:

public string Details 
{ 
    get 
    { 
        return string.Format("{0}\n{1}\n{2}\n{3}", Name, Department, Position, DOB); 
    } 
}
Chris Doggett