473,385 Members | 1,400 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,385 software developers and data experts.

Displaying a set of questions

Hi, I am using Visual C# window to dispaly a set of questions with their
answers. The users should be able to move to the next question by clicking on
next button. I am going to use only one panel to display one question and
move to next question. Can someone please help me with the codes on coding
"Next" button?
Thanks
--
Nejadian
Jun 27 '08 #1
16 2064

"Tammy Nejadian" <Ta***********@discussions.microsoft.comwrote in message
news:16**********************************@microsof t.com...
Hi, I am using Visual C# window to dispaly a set of questions with their
answers. The users should be able to move to the next question by clicking
on
next button. I am going to use only one panel to display one question and
move to next question. Can someone please help me with the codes on
coding
"Next" button?
Thanks
You need to hook up a datagrid with horizontal and vertical bars to move up
and down the questions or left or right on a question, with all the
questions being asked on one screen maybe two the at most.

From an end-user standpoint, there is nothing worst than going through 100
screens of individual questions (one question per screen) because the
programmer couldn't come up with something else that was better.

All the end-user is going to say is "who wrote this thing".

Jun 27 '08 #2
<snip>

Mr. Arnold: regarding your comments:
From an end-user standpoint, there is nothing worst than going through 100
screens of individual questions (one question per screen) because the
programmer couldn't come up with something else that was better.
This is just plain bad advice and/or guidance. There are many good reasons
to present one question at a time. Online examinations typically present one
question at a time, with the ability at the end to jump directly back to any
question to review the answer before completing the exam. Over the years I
have passed 19 Microsoft certification exams, and every one of them presents
one question at a time, with 'next' and 'back' buttons, like what the OP
apparently wants to provide.

-RC

Jun 27 '08 #3

"Robert Cramer" <A@B.comwrote in message
news:up**************@TK2MSFTNGP05.phx.gbl...
<snip>

Mr. Arnold: regarding your comments:
>From an end-user standpoint, there is nothing worst than going through
100 screens of individual questions (one question per screen) because
the programmer couldn't come up with something else that was better.

This is just plain bad advice and/or guidance. There are many good reasons
to present one question at a time. Online examinations typically present
one question at a time, with the ability at the end to jump directly back
to any question to review the answer before completing the exam. Over the
years I have passed 19 Microsoft certification exams, and every one of
them presents one question at a time, with 'next' and 'back' buttons, like
what the OP apparently wants to provide.

You don't know what the case or the scope of the questions will be for a
given solution.

I have worked on insurance applications that asked the insurance agent or
broker over 900 questions in various categories, with all of it being
displayed on one ASP.net page by selecting the various categories from combo
boxes with any where from 1 to 50 questions at a time with the answers to
questions given in combo, textbox and radio controls in a table or grid, and
all of it being built on the fly.

I have also done the same thing with questionnaire surveys for car companies
and their dealerships with their customers when asking about features in
cars based on make and model.

You can pass 10,000 MS certification tests with screen by screen questions.
That doesn't make it a standard that should be followed.

There was this one programmer who did just that. He developed a solution for
some in-house users that went screen by screen or page by page asking
questions, they wouldn't use his application, and they talked about him
like a dog.

You don't know the scope of the of this, what I have suggest my be the best
approach, and the OP doesn't know that or doesn't know any better, not to go
screen by screen.

One programs the screen by screen solution may be a viable solution, but on
the other hand, it may not be a viable solution too.
Jun 27 '08 #4
Responses inline:

>Mr. Arnold: regarding your comments:
>>From an end-user standpoint, there is nothing worst than going through
100 screens of individual questions (one question per screen) because
the programmer couldn't come up with something else that was better.

This is just plain bad advice and/or guidance. There are many good
reasons to present one question at a time. Online examinations typically
present one question at a time, with the ability at the end to jump
directly back to any question to review the answer before completing the
exam. Over the years I have passed 19 Microsoft certification exams, and
every one of them presents one question at a time, with 'next' and 'back'
buttons, like what the OP apparently wants to provide.


You don't know what the case or the scope of the questions will be for a
given solution.

I have worked on insurance applications that asked the insurance agent or
broker over 900 questions in various categories, with all of it being
displayed on one ASP.net page by selecting the various categories from
combo boxes with any where from 1 to 50 questions at a time with the
answers to questions given in combo, textbox and radio controls in a table
or grid, and all of it being built on the fly.
It sounds like you provided an excellent solution for their specific
problem. You are to be commended.

I have also done the same thing with questionnaire surveys for car
companies and their dealerships with their customers when asking about
features in cars based on make and model.
You apparently did a good thing, yet again.

You can pass 10,000 MS certification tests with screen by screen
questions. That doesn't make it a standard that should be followed.
I never stated or implied that what I was recommending was a standard. The
point I was making was that for some tests, it is perfectly reasonable to
present one question at a time. By bringing up the MS certification exams, I
was simply illustrating a real-world example of where this might be the best
approach. By stating the number of exams, I was pointing out that my
observations and experience are not entirely unique to one special case.

There was this one programmer who did just that. He developed a solution
for some in-house users that went screen by screen or page by page asking
questions, they wouldn't use his application, and they talked about him
like a dog.
So apparently he did the wrong thing. But that doesn't mean that presenting
one question at a time is always the wrong thing. Apparently you are
unfamiliar with progressive tests whereby expertise in some subject matter
is being measured via some "progressively determined" or dynamic set of
questions... whereby answers to early questions determine which questions
are presented next. Where expertise is confirmed early in a test, future
questions on that subject domain are omitted. Where expertise is not clearly
demonstrated, additional questions within the subject domain are dynamically
added to the exam... all this in an effort to get a more accurate
understanding of the expertise being measured. There is a lot of theory that
goes into these types of tests. You can google "psychometrics" for more.

Furthermore, what about plain ole' wizards. Sometimes they will present a
single question that determines what successive wizard pages are presented.

You don't know the scope of the of this, what I have suggest my be the
best approach, and the OP doesn't know that or doesn't know any better,
not to go screen by screen.
You don't know enough about the OP's motivations either, and jumped to a
conclusion that the OP doesn't know any better. I was simply pointing out
that you are wrong about that, provided some real-world examples (at least
19 that I have firsthand knowledge of).

My intention is to not be confrontational - but where somebody (the OP in
this case) is given bad advice, I'll point that out.... as doing so helps to
maintain the value of these NGs.

One programs the screen by screen solution may be a viable solution, but
on the other hand, it may not be a viable solution too.
Great! Apparently we agree. It's too bad that you didn't consider that with
your response to the OP and instead had to imply that the OP was doing
something wrong and proceeded to give very explicit advice to do something
based on your assumptions. To quote you: "You need to hook up a datagrid
with horizontal and vertical bars to move up and down the questions or left
or right on a question...". There is nothing there, or elsewhere in your
post, that helps the OP to solve their original problem.
-RC

Jun 27 '08 #5

"Robert Cramer" <A@B.comwrote in message
news:u5**************@TK2MSFTNGP03.phx.gbl...
Responses inline:

Great! Apparently we agree. It's too bad that you didn't consider that
with your response to the OP and instead had to imply that the OP was
doing something wrong and proceeded to give very explicit advice to do
something based on your assumptions. To quote you: "You need to hook up a
datagrid with horizontal and vertical bars to move up and down the
questions or left or right on a question...". There is nothing there, or
elsewhere in your post, that helps the OP to solve their original problem.

My goodness, It was a suggestion, and you made it much ado about nothing.
You would have been better off just posting to the OP, IMO.
Jun 27 '08 #6
One of your previous questions indicated you have a class containing the
question and the potential answers. Presuming this is still the case, I
recommend you create a user control which has a property for your Question
class.

The user control then handles the display of the question and answers. Your
form will have this control on it, as well as the Questions list of Question
objects. You then just incriment a counter in the list to go with the [Next]
button. Trap the condition where you are at the end of the list.

You can also add a [Previous] button which decriments the counter. In each
of these buttons you would simply update the Question object for the user
control and it would then display the new question.

"Tammy Nejadian" wrote:
Hi, I am using Visual C# window to dispaly a set of questions with their
answers. The users should be able to move to the next question by clicking on
next button. I am going to use only one panel to display one question and
move to next question. Can someone please help me with the codes on coding
"Next" button?
Thanks
--
Nejadian
Jun 27 '08 #7
On Apr 20, 10:53 pm, Tammy Nejadian
<TammyNejad...@discussions.microsoft.comwrote:
Hi, I am using Visual C# window to dispaly a set of questions with their
answers. The users should be able to move to the next question by clicking on
next button. I am going to use only one panel to display one question and
move to next question. Can someone please help me with the codes on coding
"Next" button?
Thanks
--
Nejadian
you don't provide enough information to determine what you really
want;
Is the set of questions displayed, or is a single question displayed
ata a time?
You say one question on one panel - but do you mean you want to
display many panels on the window simultaneously or a single panel on
the window, whose contents change (to the next question) when the next
button is preessed (like a wizard).

You also don't say how your questions (and answers) are stored. Are
they a collection of objects, a dataset, or something else?

Whatever the answers to the above, the essential code when clicking
the next button would be;

if (!WereLookingAtTheLastQuestion())
{
LookAtTheNextQuestion();
}

What you now need to figure out, is what will be in the two methods
WereLookingAtTheLastQuestion() and LookAtTheNextQuestion()

Assuming the questions are in an array, this could be as simple as
checking the current index against the array bounds, and incrementing
the current index and calling your 'display a question' method.

Good luck - and don't listen to those that tell you you're doing the
wrong thing when they don't know what you are doing!

..\\axxx
Jun 27 '08 #8
Thanks for your sugestions and advice. I am really appricated. I should be
more specific and explain my problem more clear. Actuly I suppose to read
from xml file and display the elements as questions and their answers. I am
able to create a panel and display the question in created label and display
the answers using radio buttons so the users can intract with them. I should
use one panel and display each question at the time and each time the user
click on button it will collect the information and display (or move to) the
next question. There should be another button which allows the user to go
back to last question if he/she wants to do that. However for now I am stock
in moving to next quesion. Could you please help me on that.
--
Nejadian
".\\\\axxx" wrote:
On Apr 20, 10:53 pm, Tammy Nejadian
<TammyNejad...@discussions.microsoft.comwrote:
Hi, I am using Visual C# window to dispaly a set of questions with their
answers. The users should be able to move to the next question by clicking on
next button. I am going to use only one panel to display one question and
move to next question. Can someone please help me with the codes on coding
"Next" button?
Thanks
--
Nejadian

you don't provide enough information to determine what you really
want;
Is the set of questions displayed, or is a single question displayed
ata a time?
You say one question on one panel - but do you mean you want to
display many panels on the window simultaneously or a single panel on
the window, whose contents change (to the next question) when the next
button is preessed (like a wizard).

You also don't say how your questions (and answers) are stored. Are
they a collection of objects, a dataset, or something else?

Whatever the answers to the above, the essential code when clicking
the next button would be;

if (!WereLookingAtTheLastQuestion())
{
LookAtTheNextQuestion();
}

What you now need to figure out, is what will be in the two methods
WereLookingAtTheLastQuestion() and LookAtTheNextQuestion()

Assuming the questions are in an array, this could be as simple as
checking the current index against the array bounds, and incrementing
the current index and calling your 'display a question' method.

Good luck - and don't listen to those that tell you you're doing the
wrong thing when they don't know what you are doing!

..\\axxx
Jun 27 '08 #9

"Tammy Nejadian" <Ta***********@discussions.microsoft.comwrote in message
news:90**********************************@microsof t.com...
Thanks for your sugestions and advice. I am really appricated. I should be
more specific and explain my problem more clear. Actuly I suppose to read
from xml file and display the elements as questions and their answers. I
am
able to create a panel and display the question in created label and
display
the answers using radio buttons so the users can intract with them. I
should
use one panel and display each question at the time and each time the user
click on button it will collect the information and display (or move to)
the
next question. There should be another button which allows the user to go
back to last question if he/she wants to do that. However for now I am
stock
in moving to next quesion. Could you please help me on that.
You read the XML with the tags of questions, you make an QuestionAnswer
object containing a property for the Question and a property for the Answer,
you load each QuestionAnswer with the Question from the XML, and you load
the QuestionAnswer object in to a List of QuestionAnswer objects. or you can
use an ArrayList too.

With the reading of each XML Question Element, you create the Object and
you load the question from the XML. It could be something like this.

private void LoadIntitialQuestions()
{

List<QuestionAnswerquestionsanswers = new <QuestionAnswer>();
Read XML Question with a read loop;

QuestionAnswer qa = new QuestionAnswer();
qa.Question = XML.Question;
qa.Answer = null; // or whatever it takes to set it to not used.

questionsanswers .Add(qa);

}

Now you have all the initial QuestionAnswer objects in a List where you can
use an index to apply the Next or Back button as you move up and down the
List by index with 0 being the first element in the list and
questionsanswers.Count being the last possible element in the List.

Idx = 0;

Label1.Text = questionsanswers [idx].question;
textbox1.Text = questionsanswers[idx].answer;

Next button will increment idx = idx++ // by 1 until it hits the max count

You do the Back button the same way but idx = idx-- decrement by 1 until it
hits 0.

If you want to save the answer to a question to the object, it would be like
this.

questionsanswers[idx].answer = textbox1.text;

It's all based off of the QuestionAnswer object being loaded into a List or
ArrayList of QuestionsAnswers, and then you can move up and down the List of
objects and address them using an Index into the List of objects.



Jun 27 '08 #10
Thanks for the information. It seems that is what I am looking for, however
one of the codes gives me error message. I add a copy of my xml file and the
class I have that may give you better picture. I am really appreciating your
help.

class QuestionAnswer
{

private string qtext;
private string AnswerText;

public string Question1
{
get { return qtext; }
set { qtext = value; }
}

public string Question2
{
get { return AnswerText; }
set { AnswerText = value; }
}

public void loadTest()
{
XmlTextReader docTest = new XmlTextReader("QuestionAnswer.xml");

string stringElement1;
while (docTest.NodeType == XmlNodeType.Element)
{
for (int tabInteger = 0; tabInteger < docTest.Depth;
tabInteger++)

stringElement1 = docTest.Name;
if (docTest.NodeType == XmlNodeType.Text)
{
string stringElement2 = docTest.Value;
}
}

}

//The xml file:
<?xml version="1.0"?>
<tests>
<test>
<testid>3</testid>
<testass>Assessment</testass>
<questions>
<question>
<Question1ID>102</Question1ID>
<testid>3</testid>
<tqorderid>10</tqorderid>
<qtext>How Old are you?</qtext>
<Answers>
<Answer>
<Answer1ID>1</Answer1ID>
<AnswerText>Below 18</AnswerText>
</Answer>
<Answer>
<Answer1ID>2</Answer1ID>
<AnswerText>Above 18</AnswerText>
</Answer>
</Answers>
</question>
<question>
<Question1ID>202</Question1ID>
<testid>3</testid>
<tqorderid>20</tqorderid>
<qtext>How many sisters and brothers you have?</qtext>
<Answers>
<Answer>
<Answer1ID>1</Answer1ID>
<AnswerText>One</AnswerText>
</Answer>
<Answer>
<Answer1ID>2</Answer1ID>
<AnswerText>Two</AnswerText>
</Answer>
<Answer>
<Answer1ID>3</Answer1ID>
<AnswerText>Three</AnswerText>
</Answer>
<Answer>
<Answer1ID>4</Answer1ID>
<AnswerText>Four</AnswerText>
</Answer>
</Answers>
</question>
<test>
<testid>4</testid>
<testass>Assessment2</testass>
</test>
</questions>
</test>
</tests>
--
Nejadian
"Mr. Arnold" wrote:
>
"Tammy Nejadian" <Ta***********@discussions.microsoft.comwrote in message
news:90**********************************@microsof t.com...
Thanks for your sugestions and advice. I am really appricated. I should be
more specific and explain my problem more clear. Actuly I suppose to read
from xml file and display the elements as questions and their answers. I
am
able to create a panel and display the question in created label and
display
the answers using radio buttons so the users can intract with them. I
should
use one panel and display each question at the time and each time the user
click on button it will collect the information and display (or move to)
the
next question. There should be another button which allows the user to go
back to last question if he/she wants to do that. However for now I am
stock
in moving to next quesion. Could you please help me on that.

You read the XML with the tags of questions, you make an QuestionAnswer
object containing a property for the Question and a property for the Answer,
you load each QuestionAnswer with the Question from the XML, and you load
the QuestionAnswer object in to a List of QuestionAnswer objects. or you can
use an ArrayList too.

With the reading of each XML Question Element, you create the Object and
you load the question from the XML. It could be something like this.

private void LoadIntitialQuestions()
{

List<QuestionAnswerquestionsanswers = new <QuestionAnswer>();
Read XML Question with a read loop;

QuestionAnswer qa = new QuestionAnswer();
qa.Question = XML.Question;
qa.Answer = null; // or whatever it takes to set it to not used.

questionsanswers .Add(qa);

}

Now you have all the initial QuestionAnswer objects in a List where you can
use an index to apply the Next or Back button as you move up and down the
List by index with 0 being the first element in the list and
questionsanswers.Count being the last possible element in the List.

Idx = 0;

Label1.Text = questionsanswers [idx].question;
textbox1.Text = questionsanswers[idx].answer;

Next button will increment idx = idx++ // by 1 until it hits the max count

You do the Back button the same way but idx = idx-- decrement by 1 until it
hits 0.

If you want to save the answer to a question to the object, it would be like
this.

questionsanswers[idx].answer = textbox1.text;

It's all based off of the QuestionAnswer object being loaded into a List or
ArrayList of QuestionsAnswers, and then you can move up and down the List of
objects and address them using an Index into the List of objects.



Jun 27 '08 #11

"Tammy Nejadian" <Ta***********@discussions.microsoft.comwrote in message
news:C9**********************************@microsof t.com...
Thanks for the information. It seems that is what I am looking for,
however
one of the codes gives me error message. I add a copy of my xml file and
the
class I have that may give you better picture. I am really appreciating
your
help.
What error message would that be and at what point does the application
blow-up?

Jun 27 '08 #12
I used your code you posted. I named my class QuestionAnswer same as my xml
file name however I get error message on this line:

List<QuestionAnswerquestionsanswers = new <QuestionAnswer>();

it says
--
Nejadian
"Tammy Nejadian" wrote:
Thanks for the information. It seems that is what I am looking for, however
one of the codes gives me error message. I add a copy of my xml file and the
class I have that may give you better picture. I am really appreciating your
help.

class QuestionAnswer
{

private string qtext;
private string AnswerText;

public string Question1
{
get { return qtext; }
set { qtext = value; }
}

public string Question2
{
get { return AnswerText; }
set { AnswerText = value; }
}

public void loadTest()
{
XmlTextReader docTest = new XmlTextReader("QuestionAnswer.xml");

string stringElement1;
while (docTest.NodeType == XmlNodeType.Element)
{
for (int tabInteger = 0; tabInteger < docTest.Depth;
tabInteger++)

stringElement1 = docTest.Name;
if (docTest.NodeType == XmlNodeType.Text)
{
string stringElement2 = docTest.Value;
}
}

}

//The xml file:
<?xml version="1.0"?>
<tests>
<test>
<testid>3</testid>
<testass>Assessment</testass>
<questions>
<question>
<Question1ID>102</Question1ID>
<testid>3</testid>
<tqorderid>10</tqorderid>
<qtext>How Old are you?</qtext>
<Answers>
<Answer>
<Answer1ID>1</Answer1ID>
<AnswerText>Below 18</AnswerText>
</Answer>
<Answer>
<Answer1ID>2</Answer1ID>
<AnswerText>Above 18</AnswerText>
</Answer>
</Answers>
</question>
<question>
<Question1ID>202</Question1ID>
<testid>3</testid>
<tqorderid>20</tqorderid>
<qtext>How many sisters and brothers you have?</qtext>
<Answers>
<Answer>
<Answer1ID>1</Answer1ID>
<AnswerText>One</AnswerText>
</Answer>
<Answer>
<Answer1ID>2</Answer1ID>
<AnswerText>Two</AnswerText>
</Answer>
<Answer>
<Answer1ID>3</Answer1ID>
<AnswerText>Three</AnswerText>
</Answer>
<Answer>
<Answer1ID>4</Answer1ID>
<AnswerText>Four</AnswerText>
</Answer>
</Answers>
</question>
<test>
<testid>4</testid>
<testass>Assessment2</testass>
</test>
</questions>
</test>
</tests>
--
Nejadian
"Mr. Arnold" wrote:

"Tammy Nejadian" <Ta***********@discussions.microsoft.comwrote in message
news:90**********************************@microsof t.com...
Thanks for your sugestions and advice. I am really appricated. I should be
more specific and explain my problem more clear. Actuly I suppose to read
from xml file and display the elements as questions and their answers. I
am
able to create a panel and display the question in created label and
display
the answers using radio buttons so the users can intract with them. I
should
use one panel and display each question at the time and each time the user
click on button it will collect the information and display (or move to)
the
next question. There should be another button which allows the user to go
back to last question if he/she wants to do that. However for now I am
stock
in moving to next quesion. Could you please help me on that.
You read the XML with the tags of questions, you make an QuestionAnswer
object containing a property for the Question and a property for the Answer,
you load each QuestionAnswer with the Question from the XML, and you load
the QuestionAnswer object in to a List of QuestionAnswer objects. or you can
use an ArrayList too.

With the reading of each XML Question Element, you create the Object and
you load the question from the XML. It could be something like this.

private void LoadIntitialQuestions()
{

List<QuestionAnswerquestionsanswers = new <QuestionAnswer>();
Read XML Question with a read loop;

QuestionAnswer qa = new QuestionAnswer();
qa.Question = XML.Question;
qa.Answer = null; // or whatever it takes to set it to not used.

questionsanswers .Add(qa);

}

Now you have all the initial QuestionAnswer objects in a List where you can
use an index to apply the Next or Back button as you move up and down the
List by index with 0 being the first element in the list and
questionsanswers.Count being the last possible element in the List.

Idx = 0;

Label1.Text = questionsanswers [idx].question;
textbox1.Text = questionsanswers[idx].answer;

Next button will increment idx = idx++ // by 1 until it hits the max count

You do the Back button the same way but idx = idx-- decrement by 1 until it
hits 0.

If you want to save the answer to a question to the object, it would be like
this.

questionsanswers[idx].answer = textbox1.text;

It's all based off of the QuestionAnswer object being loaded into a List or
ArrayList of QuestionsAnswers, and then you can move up and down the List of
objects and address them using an Index into the List of objects.




Jun 27 '08 #13
Tammy,

I used your class, creating an instance of it, and called the loadTest
method. The while loop is never entered, and so Question1 and Question2 both
return "".

Regarding your message about using Mr. Arnold's code, you said:

List<QuestionAnswerquestionsanswers = new <QuestionAnswer>();
That should fail. The line (I believe) should be:

List<QuestionAnswerquestionanswers = new List<QuestionAnswer>();
"Tammy Nejadian" wrote:
Thanks for the information. It seems that is what I am looking for, however
one of the codes gives me error message. I add a copy of my xml file and the
class I have that may give you better picture. I am really appreciating your
help.

class QuestionAnswer
{

private string qtext;
private string AnswerText;

public string Question1
{
get { return qtext; }
set { qtext = value; }
}

public string Question2
{
get { return AnswerText; }
set { AnswerText = value; }
}

public void loadTest()
{
XmlTextReader docTest = new XmlTextReader("QuestionAnswer.xml");

string stringElement1;
while (docTest.NodeType == XmlNodeType.Element)
{
for (int tabInteger = 0; tabInteger < docTest.Depth;
tabInteger++)

stringElement1 = docTest.Name;
if (docTest.NodeType == XmlNodeType.Text)
{
string stringElement2 = docTest.Value;
}
}

}

//The xml file:
<?xml version="1.0"?>
<tests>
<test>
<testid>3</testid>
<testass>Assessment</testass>
<questions>
<question>
<Question1ID>102</Question1ID>
<testid>3</testid>
<tqorderid>10</tqorderid>
<qtext>How Old are you?</qtext>
<Answers>
<Answer>
<Answer1ID>1</Answer1ID>
<AnswerText>Below 18</AnswerText>
</Answer>
<Answer>
<Answer1ID>2</Answer1ID>
<AnswerText>Above 18</AnswerText>
</Answer>
</Answers>
</question>
<question>
<Question1ID>202</Question1ID>
<testid>3</testid>
<tqorderid>20</tqorderid>
<qtext>How many sisters and brothers you have?</qtext>
<Answers>
<Answer>
<Answer1ID>1</Answer1ID>
<AnswerText>One</AnswerText>
</Answer>
<Answer>
<Answer1ID>2</Answer1ID>
<AnswerText>Two</AnswerText>
</Answer>
<Answer>
<Answer1ID>3</Answer1ID>
<AnswerText>Three</AnswerText>
</Answer>
<Answer>
<Answer1ID>4</Answer1ID>
<AnswerText>Four</AnswerText>
</Answer>
</Answers>
</question>
<test>
<testid>4</testid>
<testass>Assessment2</testass>
</test>
</questions>
</test>
</tests>
--
Nejadian
"Mr. Arnold" wrote:

"Tammy Nejadian" <Ta***********@discussions.microsoft.comwrote in message
news:90**********************************@microsof t.com...
Thanks for your sugestions and advice. I am really appricated. I should be
more specific and explain my problem more clear. Actuly I suppose to read
from xml file and display the elements as questions and their answers. I
am
able to create a panel and display the question in created label and
display
the answers using radio buttons so the users can intract with them. I
should
use one panel and display each question at the time and each time the user
click on button it will collect the information and display (or move to)
the
next question. There should be another button which allows the user to go
back to last question if he/she wants to do that. However for now I am
stock
in moving to next quesion. Could you please help me on that.
You read the XML with the tags of questions, you make an QuestionAnswer
object containing a property for the Question and a property for the Answer,
you load each QuestionAnswer with the Question from the XML, and you load
the QuestionAnswer object in to a List of QuestionAnswer objects. or you can
use an ArrayList too.

With the reading of each XML Question Element, you create the Object and
you load the question from the XML. It could be something like this.

private void LoadIntitialQuestions()
{

List<QuestionAnswerquestionsanswers = new <QuestionAnswer>();
Read XML Question with a read loop;

QuestionAnswer qa = new QuestionAnswer();
qa.Question = XML.Question;
qa.Answer = null; // or whatever it takes to set it to not used.

questionsanswers .Add(qa);

}

Now you have all the initial QuestionAnswer objects in a List where you can
use an index to apply the Next or Back button as you move up and down the
List by index with 0 being the first element in the list and
questionsanswers.Count being the last possible element in the List.

Idx = 0;

Label1.Text = questionsanswers [idx].question;
textbox1.Text = questionsanswers[idx].answer;

Next button will increment idx = idx++ // by 1 until it hits the max count

You do the Back button the same way but idx = idx-- decrement by 1 until it
hits 0.

If you want to save the answer to a question to the object, it would be like
this.

questionsanswers[idx].answer = textbox1.text;

It's all based off of the QuestionAnswer object being loaded into a List or
ArrayList of QuestionsAnswers, and then you can move up and down the List of
objects and address them using an Index into the List of objects.




Jun 27 '08 #14
Thanks, it solved the problem. Many thanks to all of you, I am really
appreciated your help.
--
Nejadian
"Family Tree Mike" wrote:
Tammy,

I used your class, creating an instance of it, and called the loadTest
method. The while loop is never entered, and so Question1 and Question2 both
return "".

Regarding your message about using Mr. Arnold's code, you said:

List<QuestionAnswerquestionsanswers = new <QuestionAnswer>();
That should fail. The line (I believe) should be:

List<QuestionAnswerquestionanswers = new List<QuestionAnswer>();
"Tammy Nejadian" wrote:
Thanks for the information. It seems that is what I am looking for, however
one of the codes gives me error message. I add a copy of my xml file and the
class I have that may give you better picture. I am really appreciating your
help.

class QuestionAnswer
{

private string qtext;
private string AnswerText;

public string Question1
{
get { return qtext; }
set { qtext = value; }
}

public string Question2
{
get { return AnswerText; }
set { AnswerText = value; }
}

public void loadTest()
{
XmlTextReader docTest = new XmlTextReader("QuestionAnswer.xml");

string stringElement1;
while (docTest.NodeType == XmlNodeType.Element)
{
for (int tabInteger = 0; tabInteger < docTest.Depth;
tabInteger++)

stringElement1 = docTest.Name;
if (docTest.NodeType == XmlNodeType.Text)
{
string stringElement2 = docTest.Value;
}
}

}

//The xml file:
<?xml version="1.0"?>
<tests>
<test>
<testid>3</testid>
<testass>Assessment</testass>
<questions>
<question>
<Question1ID>102</Question1ID>
<testid>3</testid>
<tqorderid>10</tqorderid>
<qtext>How Old are you?</qtext>
<Answers>
<Answer>
<Answer1ID>1</Answer1ID>
<AnswerText>Below 18</AnswerText>
</Answer>
<Answer>
<Answer1ID>2</Answer1ID>
<AnswerText>Above 18</AnswerText>
</Answer>
</Answers>
</question>
<question>
<Question1ID>202</Question1ID>
<testid>3</testid>
<tqorderid>20</tqorderid>
<qtext>How many sisters and brothers you have?</qtext>
<Answers>
<Answer>
<Answer1ID>1</Answer1ID>
<AnswerText>One</AnswerText>
</Answer>
<Answer>
<Answer1ID>2</Answer1ID>
<AnswerText>Two</AnswerText>
</Answer>
<Answer>
<Answer1ID>3</Answer1ID>
<AnswerText>Three</AnswerText>
</Answer>
<Answer>
<Answer1ID>4</Answer1ID>
<AnswerText>Four</AnswerText>
</Answer>
</Answers>
</question>
<test>
<testid>4</testid>
<testass>Assessment2</testass>
</test>
</questions>
</test>
</tests>
--
Nejadian
"Mr. Arnold" wrote:
>
"Tammy Nejadian" <Ta***********@discussions.microsoft.comwrote in message
news:90**********************************@microsof t.com...
Thanks for your sugestions and advice. I am really appricated. I should be
more specific and explain my problem more clear. Actuly I suppose to read
from xml file and display the elements as questions and their answers. I
am
able to create a panel and display the question in created label and
display
the answers using radio buttons so the users can intract with them. I
should
use one panel and display each question at the time and each time the user
click on button it will collect the information and display (or move to)
the
next question. There should be another button which allows the user to go
back to last question if he/she wants to do that. However for now I am
stock
in moving to next quesion. Could you please help me on that.
>
You read the XML with the tags of questions, you make an QuestionAnswer
object containing a property for the Question and a property for the Answer,
you load each QuestionAnswer with the Question from the XML, and you load
the QuestionAnswer object in to a List of QuestionAnswer objects. or you can
use an ArrayList too.
>
With the reading of each XML Question Element, you create the Object and
you load the question from the XML. It could be something like this.
>
private void LoadIntitialQuestions()
{
>
List<QuestionAnswerquestionsanswers = new <QuestionAnswer>();
>
>
Read XML Question with a read loop;
>
QuestionAnswer qa = new QuestionAnswer();
qa.Question = XML.Question;
qa.Answer = null; // or whatever it takes to set it to not used.
>
questionsanswers .Add(qa);
>
}
>
Now you have all the initial QuestionAnswer objects in a List where you can
use an index to apply the Next or Back button as you move up and down the
List by index with 0 being the first element in the list and
questionsanswers.Count being the last possible element in the List.
>
Idx = 0;
>
Label1.Text = questionsanswers [idx].question;
textbox1.Text = questionsanswers[idx].answer;
>
Next button will increment idx = idx++ // by 1 until it hits the max count
>
You do the Back button the same way but idx = idx-- decrement by 1 until it
hits 0.
>
If you want to save the answer to a question to the object, it would be like
this.
>
questionsanswers[idx].answer = textbox1.text;
>
It's all based off of the QuestionAnswer object being loaded into a List or
ArrayList of QuestionsAnswers, and then you can move up and down the List of
objects and address them using an Index into the List of objects.
>
>
>
>
>
>
>
>
>
>
>
>
Jun 27 '08 #15

"Family Tree Mike" <Fa************@discussions.microsoft.comwrote in
message news:46**********************************@microsof t.com...
Tammy,

I used your class, creating an instance of it, and called the loadTest
method. The while loop is never entered, and so Question1 and Question2
both
return "".

Regarding your message about using Mr. Arnold's code, you said:

List<QuestionAnswerquestionsanswers = new <QuestionAnswer>();
That should fail. The line (I believe) should be:

List<QuestionAnswerquestionanswers = new List<QuestionAnswer>();

I don't know. The least he could have done was look up the List statement.
He was lucky he got anything out of me at 3:00 am when I woke up to take a
pi$$ and went back to sleep. <g>

There is also the auto completion-key. What is it shift-key space bar-key?
The use of the key combination would have just about completed the statement
for him after the *new* key word.
Jun 27 '08 #16
I hope I get respond to this question. I posted long time ago. Anyway how I
can call and display the question and its answers when I click a button?
Thanks.
--
Nejadian
"Mr. Arnold" wrote:
>
"Family Tree Mike" <Fa************@discussions.microsoft.comwrote in
message news:46**********************************@microsof t.com...
Tammy,

I used your class, creating an instance of it, and called the loadTest
method. The while loop is never entered, and so Question1 and Question2
both
return "".

Regarding your message about using Mr. Arnold's code, you said:

List<QuestionAnswerquestionsanswers = new <QuestionAnswer>();
That should fail. The line (I believe) should be:

List<QuestionAnswerquestionanswers = new List<QuestionAnswer>();

I don't know. The least he could have done was look up the List statement.
He was lucky he got anything out of me at 3:00 am when I woke up to take a
pi$$ and went back to sleep. <g>

There is also the auto completion-key. What is it shift-key space bar-key?
The use of the key combination would have just about completed the statement
for him after the *new* key word.
Jun 27 '08 #17

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

2
by: Steven | last post by:
Hi there, I have a list of values that I am displaying in a table (Not using a loop) I want to be able to put a graphic next to the item with the hightest price. I have all of the prices in...
5
by: Mystery | last post by:
Can anyone point me to a script that will allow me to list x number of records per page and give me a page selector and information like the one in the subject header? Thanks.
1
by: tapan t | last post by:
Hello, I've two SQL tables. Q_Master(Q_ID,Question_DET,DIS_MODE) and ANS_MASTER(ANS_ID,ANSWERS,QUESTION_ID,SCORE) There are lot of questions in the database and answers for that respective...
13
by: Aladdin | last post by:
I have an MS Access form on which I have a listbox listing tables in that database. I want to be able to click on any of those tables and view its contents on the same form using subforms or any...
3
by: Frank | last post by:
Hi! I just run into a problem wich some of you might be able to solve really quickly so i decided to give this group a shot. In the database a have 2 tables (well, to make it easy here). 1)...
18
by: John | last post by:
Hi I am trying to display an image in a dialog using the following code; Dim frm As New frmImage Dim z As System.Drawing.Bitmap z.FromFile("c:\temp\image.gif") frm.picImage.Image = z...
15
by: Jameson | last post by:
Happy New Year, Everyone! I am trying to figure out how to display a bunch of images (mainly JPEGs, but possibly a few GIFs and PNGs as well) that are stored in a local directory on the system....
4
by: Drew | last post by:
I posted this to the asp.db group, but it doesn't look like there is much activity on there, also I noticed that there are a bunch of posts on here pertaining to database and asp. Sorry for...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.