Click here to Skip to main content
Rate this: bad
good
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 4: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 at 13-Nov-12 10:34am
   
It is a desktop application in c#
Christian Graus at 13-Nov-12 10:37am
   
Still not enough. Winforms ? WPF ?
lilian87 at 13-Nov-12 10:38am
   
winforms
Christian Graus at 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
0 Sergey Alexandrovich Kryukov 353
1 OriginalGriff 304
2 George Jonsson 258
3 Shemeemsha RA 138
4 Animesh Datta 130
0 OriginalGriff 5,985
1 Sergey Alexandrovich Kryukov 5,341
2 CPallini 4,760
3 George Jonsson 3,400
4 Gihan Liyanage 2,522


Advertise | Privacy | Mobile
Web01 | 2.8.140916.1 | Last Updated 13 Nov 2012
Copyright © CodeProject, 1999-2014
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