Alex Rivera | Logout

Dynamic UI Generation in C#

Asked 2010-08-28T06:10:02.943
10

I am designing an application for a library. Not a large scale library, but a very small scale library where my primary task is to just keep information about the books. But this library application should be able to adapt to any professional's private library. For an example, for a lawyer, apart from the basic information about the book (title, author, publisher etc), there maybe other special fields that is associated with a book (Case Number, Court Number etc). A doctor may have some other special attributes for a book. Same goes for other professions.

So I am going to use an SQL Server CE database and I am hoping to have a BOOK table with the usual attributes and on demand ALTER the table to suit the special needs (add more columns).

But my worry is generating the GUI dynamically to support the new attributes.

Are there any approaches to tackle the dynamic GUI generation?

I am not asking for complete code (which obviously I wont get), but if you do have any coding to support the approach, please be kind enough to post it :)

Is there anything I should know about the pros, cons, dead ends, cautions or warnings etc?

Edit
Report

1 Answer

4

I don't know if altering the table dynamically is a good design decision. You could instead have a lookup table in which you can define detail types, and a books detail table in which you would store these details. Then you can display these details in the book editing section in the form of a datagrid that has the detail types as rows, each row having a column in which you would edit the value. Of course, the detail of a book can be anything else than a simple string value but this can be handled with ease. Hope i was clear enough :)

-------------           -----------------          ----------------
|  Books    |           |  BooksDetail  |          |  DetailTypes |
-------------           -----------------          ----------------
| ID (PK)   | 1      n  | ID (PK)       | 1     1  | ID (PK)      |
| AuthorID  | --------> | BookID        | -------> | Name         |
| Title     |           | DetailID      |          | Description  |
| Year      |           | Value         |          ----------------
-------------           -----------------
answered 2010-08-28T06:53:58.260

Your Answer