|
I think what you're asking is how to get the result of the click back to the main form.
When you open the form that has the buttons, use .ShowDialog, rather than just .Show, and the results of the button click (as OrginalGriff showed) can be returned to the calling form easily.
|
|
|
|
|
From what the OP describes, I cannot tell if he is using a separated Form to display the quesstion.
«One day it will have to be officially admitted that what we have christened reality is an even greater illusion than the world of dreams.» Salvador Dali
|
|
|
|
|
First, are you using one Form for all this, or more than one Form ?
«One day it will have to be officially admitted that what we have christened reality is an even greater illusion than the world of dreams.» Salvador Dali
|
|
|
|
|
Thanks Bill and RenJerDan for your replies.
To go more into detail.
Once the user has pressed the start button a d the question is displayed to the user then the user has a choice of clicking on the YES or the NO buttons.
For a forms program once the program has displayed the question it is waiting for the user to press a button on the form, but if the user pressed the YES button then control switches to the Yes_Click code which is just YN=1 but then I need to return to the main code to make a decision depending on what button was pressed. It's not like the main code will wait for the user to make a choice before continuing.
I tried to create a loop that continues until YN is equal to anything other than zero but while in the loop it is not checking on the buttons on the form, which Makes me wonder how arcade games work as they are looping to provide animation.
|
|
|
|
|
@Brian_TheLion Hi Brian, I still don't know if the question is displayed in its own Form, rather than on a "Main Form." That's important to know in order to assist you. cheers, Bill
«One day it will have to be officially admitted that what we have christened reality is an even greater illusion than the world of dreams.» Salvador Dali
|
|
|
|
|
I'm using one form only Bill.
Brian
|
|
|
|
|
Here's how I would approach this:
flow-of-control: a GroupBox is shown with a current question; the user must click one of two radio-buttons to enable a Button that moves to the next question. Next questions are presented until the list of questions is enumerated.
0 a Button that will start the quiz 'btnShowQuiz: visible on the Main Form
1 a GroupBox 'grpbxQuiz: set not visible containing:
a TextBox 'tbxQuizQuestion
two RadioButtons 'rbtnYes 'rbtnNo : the 'CheckChanged for both these RadioButtons is set to 'rbtn_CheckedChanged
a Button 'btnNextQuestion
private bool ignoreRBCheckEvent = true;
private List<string> questions = new List<string>
{
"who", "when", "where", "how"
};
private Dictionary<int, bool> QA = new Dictionary<int, bool>();
private int qcnt = 0;
private void btnShowQuiz_Click(object sender, EventArgs e)
{
QA.Clear();
qcnt = 0;
tbxQuizQuestion.Text = questions[0];
btnNextQuestion.Enabled = false;
rbtnYes.Enabled = true;
rbtnYes.CheckedChanged += rbtn_CheckedChanged;
rbtnNo.Enabled = true;
rbtnNo.CheckedChanged += rbtn_CheckedChanged;
ignoreRBCheckEvent = false;
grpbxQuiz.Visible = true;
Cursor.Clip = grpbxQuiz.RectangleToScreen(grpbxQuiz.ClientRectangle);
}
private void BtnNextQuestion_Click(object sender, EventArgs e)
{
ignoreRBCheckEvent = true;
rbtnYes.Checked = false;
rbtnNo.Checked = false;
btnNextQuestion.Enabled = false;
tbxQuizQuestion.Text = questions[qcnt];
ignoreRBCheckEvent = false;
}
private void rbtn_CheckedChanged(object sender, EventArgs e)
{
if (ignoreRBCheckEvent) return;
QA.Add(qcnt++, rbtnYes.Checked);
if (qcnt < questions.Count)
{
btnNextQuestion.Enabled = true;
}
else
{
Cursor.Clip = Rectangle.Empty;
grpbxQuiz.Visible = false;
OnQuizFinished();
}
}
public void OnQuizFinished()
{
foreach (var kvp in QA)
{
Console.WriteLine($"({kvp.Key}) \"{questions[kvp.Key]}\" | {kvp.Value}");
}
} note the use of clipping the Cursor to restrict mouse input to the GroupBox.
«One day it will have to be officially admitted that what we have christened reality is an even greater illusion than the world of dreams.» Salvador Dali
modified 17-Sep-19 5:10am.
|
|
|
|
|
Thanks Bill for the example code you provided. I'll study it and try it out.
Brian
|
|
|
|
|
I'm sending an email with attachment generating from the code below:
private const string CsvContentType = "application/ms-excel";
.....
.....
mem.Seek(0, SeekOrigin.Begin);
Attachment attach = new Attachment(mem, "Testing.xls");
attach.ContentType = new System.Net.Mime.ContentType(CsvContentType);
mailMsg.Attachments.Add(attach);
where mem is a Stream object
I'm able to send the mail with the attachment but it is of not proper format. For example see the example below:
StudId;Name;Age;….
1;Anna;14;....
2;Emma;14;....
3;Tina;14;....
Can some one help with it?
|
|
|
|
|
Are you sure that the file is truly an Excel document? The content you posted looks like plain text with semi-colon delineation.
If that is the case, your file extension should reflect text or I suppose you could do CSV as well
The correct MIME (content-) type for a CSV file is text/csv
Director of Transmogrification Services
Shinobi of Query Language
Master of Yoda Conditional
|
|
|
|
|
I am trying to get the websocket data from the https://www.18bet.com.
The websocket url is wss://push.delasport.com:3001/socket.io/?token=...&EIO=...&sid=...
A few days ago, I got the HttpResponseText that is full html source from the server(18bet.com).
But now, I get follow text as HttpResponseText.
<html>
<head>
<META NAME="robots" CONTENT="noindex,nofollow">
<script src="/_Incapsula_Resource?SWJIYLWA=5074a744e2e3d891814e9a2dace20bd4,719d34d31c8e3a6e6fffd425f7e032f3">
</script>
<body>
</body>
</html>
I experimented this using exclusive tool ,Postman which sends request and receives reponse.
In my opinion, it looks like the server detect Robot.
Since I got above response ,the hankshake error occured in my websocket module.
The websocket module is C# code with websocketsharp.dll.
I think the websocket server is Nodejs.
How do I have to?
Help! Help! Help!
Specifically.
I will wait...
|
|
|
|
|
You should contact the owners of the website for help. But if you are trying to hack, or otherwise get illegal information, then no help will be forthcoming.
|
|
|
|
|
I don't need that sound.
|
|
|
|
|
|
I would think you'd have to contact the owner of the site.
Social Media - A platform that makes it easier for the crazies to find each other.
Everyone is born right handed. Only the strongest overcome it.
Fight for left-handed rights and hand equality.
|
|
|
|
|
Get a new IP address.
The Master said, 'Am I indeed possessed of knowledge? I am not knowing. But if a mean person, who appears quite empty-like, ask anything of me, I set it forth from one end to the other, and exhaust it.'
― Confucian Analects
|
|
|
|
|
Member 14570843 wrote: I will wait...
You most certainly will ...
Sent from my Amstrad PC 1640
Never throw anything away, Griff
Bad command or file name. Bad, bad command! Sit! Stay! Staaaay...
AntiTwitter: @DalekDave is now a follower!
|
|
|
|
|
Given a choice to either work either on a Winforms or WPF for a desktop application, what should be the pointer to consider to decide which one to Choose?
|
|
|
|
|
"Which one do I know well?" is a good start.
I stick with WinForms, just because WPF never seems "finished" - there is a lot of manual editing that you just don't need with WinForms, and that makes it feel like the WPF designer / editor is still a Beta release rather than a market-ready solution.
Sent from my Amstrad PC 1640
Never throw anything away, Griff
Bad command or file name. Bad, bad command! Sit! Stay! Staaaay...
AntiTwitter: @DalekDave is now a follower!
|
|
|
|
|
If you are not already an expert in WPF then stay with Winforms. WPF is very powerful but has quite a steep learning curve (i.e. it is quite difficult to learn to use it properly).
|
|
|
|
|
XAML (WPF / UWP) is designed to be declarative; while you can also use procedural code to create the UI. It has a designer that works at design time and while debugging.
Windows Forms is procedural only; almost impossible to work with without the "designer".
If you think you can create a web page using pure HTML(5), you can handle XAML at some level.
The Master said, 'Am I indeed possessed of knowledge? I am not knowing. But if a mean person, who appears quite empty-like, ask anything of me, I set it forth from one end to the other, and exhaust it.'
― Confucian Analects
|
|
|
|
|
Gerry Schmitz wrote: Windows Forms is procedural only; almost impossible to work with without the "designer" I been doing WinForms without the designer for years, and it's not that hard to create it from code.
I often go for WinForms when I want the app to run from my Ubuntu-machine
Bastard Programmer from Hell
If you can't read my code, try converting it here[^]
"If you just follow the bacon Eddy, wherever it leads you, then you won't have to think about politics." -- Some Bell.
|
|
|
|
|
I've worked on Windows Forms quite a bit in the past; a few commercial ones.
I once mocked WPF when it didn't have a "data grid".
With swiping, having controls that can go in 2 directions, with accuracy, becomes a challenge. You soon start making more imaginative list views; easy in WPF, even more in UWP, nearly impossible in Windows Forms. And so on.
If you're "creative", you "need" the WPF / UWP model.
The Master said, 'Am I indeed possessed of knowledge? I am not knowing. But if a mean person, who appears quite empty-like, ask anything of me, I set it forth from one end to the other, and exhaust it.'
― Confucian Analects
|
|
|
|
|
Gerry Schmitz wrote: If you're "creative", you "need" the WPF / UWP model. I heard that before; for those who are not swiping, there is no issue. If I would develop something for a tablet or phone, I'd go for a website, not a rich UI.
Again, if I had no Linux-machine, I would probably have gone the WPF-route too. Having a recognizable UI, cross-platform, with tons of documentation and an experienced workforce, does count for something
It does sound somewhat ironic to have WinForms because part of your intended audience is on Linux, but that's life. WPF isn't supported there, and they like having a UI they recognize over the GTK-stuff.
Bastard Programmer from Hell
If you can't read my code, try converting it here[^]
"If you just follow the bacon Eddy, wherever it leads you, then you won't have to think about politics." -- Some Bell.
|
|
|
|
|
Never saw Unix, Linux as other than a back end for "big servers".
Used to try and cover all the bases. Found a home (finally) in C#. Then WPF. Then Windows 10, UWP and the MS Surface.
Fortunately, I only have to please myself on this one and can tell what the competition looks like.
The cost of admission is also cheaper (for me).
The Master said, 'Am I indeed possessed of knowledge? I am not knowing. But if a mean person, who appears quite empty-like, ask anything of me, I set it forth from one end to the other, and exhaust it.'
― Confucian Analects
|
|
|
|