Click here to Skip to main content
12,243,303 members (47,942 online)
Rate this:
 
Please Sign up or sign in to vote.
See more: C#
I am doing a small project in c#. It is like a questionaire. Administrator has the option to add as many questions she want and the answer type may also differ for each question.The questions are coming from database . I am storing all the questions in a datagridview. How can I create the questions and its answer type dynamically based on the number of questions in a datagridview
Posted 13-Nov-12 5:29am

1 solution

Rate this: bad
 
good
Please Sign up or sign in to vote.

Solution 1

By changing the data source to contain the questions and answers you want it to, and then writing code that can bind to that data source. There's no controls to add dynamically here, you're showing data in a databound control, so you just need to change the data. I'd expect this would be a data bound control for each question, with a databound control inside it for an arbitrary number of answers. Hard to say more, as you give no clues what you're using ( WPF, winforms, silverlight, ASP.NET, MVC, etc )
  Permalink  
Comments
lilian87 13-Nov-12 10:34am
   
It is a desktop application in c#
Christian Graus 13-Nov-12 10:37am
   
Still not enough. Winforms ? WPF ?
lilian87 13-Nov-12 10:38am
   
winforms
Christian Graus 13-Nov-12 10:54am
   
So to add a control, you just create it, set it's position ( top, width etc ) and add it to the form's 'controls' collection, as in this.Controls.Add(x);. But again, you should not need to do that

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

  Print Answers RSS
Top Experts
Last 24hrsThis month


Advertise | Privacy | Mobile
Web02 | 2.8.160426.1 | Last Updated 13 Nov 2012
Copyright © CodeProject, 1999-2016
All Rights Reserved. Terms of Service
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100