I am developing a web browser using C# and XAML.
I want to make system that when users enter texts or numbers other than the URL in a URL display form, the screen display remains the same, but only the inside of the form is automatically blanked out and ready to be reentered.
I know that I need to add something to the code below, but I don't know how.
Please help.
private void txtUrl_KeyUp(object sender, KeyEventArgs e)
{
if (e.Key == Key.Enter)
wbSample.Navigate(txtUrl.Text);
}
Related
I'm writing a program in c# (visual studio, windows forms) which involves the user selecting a name from a combo box, and then clicking a button which brings them to a quiz on another form. I want a text file to be created at the end of the quiz showing the name selected and the quiz results, followed by a "~" symbol.
I honestly don't know where to start. I'm using stream reader.
This is the code I used for the combo box and the button that sends you to the next form
private void quizSelectPupilCB_SelectedIndexChanged(object sender, EventArgs e)
{
selectedClass = quizSelectPupilCB.SelectedItem.ToString();
}
private void quizStartBTN_Click(object sender, EventArgs e)
{
Quiz2 formQuiz2 = new Quiz2();
formQuiz2.Show();
this.Hide();
}
How do I use this data on another form?
I don't even know where to start. I tried looking up things like "how to access data from one form and put it in another c#" and similar things but everything I found was either not what I was looking for, or worded in a really confusing way.
As a variant you can save selectedItem to String/StringCollection, then to app settings(Settings.Default). And on another form get this value back.
I am designing a program in Visual Studio - Windows Forms c#.net framework to log Gamertags and High Scores of entrants into a gaming competition. I have a textbox for a user to enter a Gamertag and a textbox for a user to enter a High Score, and then a button to log the Gamertag and High Score into a separate two lists.
The issue im having is around disabling the button until both the Gamertag and High Score fields have some text in them. This will be insultingly easy for a lot of you but I am not sure how to write the code to make this happen, I will show what I have:
So on initialise component I have the following:
{
btnAdd.Enabled = !string.IsNullOrEmpty(txtHighScore.Text);
btnAdd.Enabled = !string.IsNullOrEmpty(txtUsername.Text);
}
Button is disabled as soon as the program launches until text is entered.
Then further down I have code on the TextChanged sections of each text box
private void txtHighScore_TextChanged(object sender, EventArgs e)
{
btnAdd.Enabled = !string.IsNullOrEmpty(txtHighScore.Text);
}
private void txtGamertag_TextChanged(object sender, EventArgs e)
{
btnAdd.Enabled = !string.IsNullOrEmpty(txtGamertag.Text);
}
From reading this you will see that if text is entered into either box the button will be enabled, but I only want it to be enabled if text has successfully be input into BOTH fields.
You could set both textboxes TextChanged events to this method called DataChanged (you can choose the name you please)
private void DataChanged(object sender, EventArgs e)
{
btnAdd.Enabled = !string.IsNullOrWhiteSpace(txtHighScore.Text)
&& !string.IsNullOrWhiteSpace(txtGamertag.Text);
}
As you can see you have to use both checks together to enable button and for this you can take advantage of && which means and.
Naturally you could write both events with the same commands, but using just one method for both events makes clear what you're doing and there's only one point in code where you can make changes if necessary, so code is more maintainable.
Your code is not working because you enable/disable button using just one textbox at once.
I have a windows form application,there is a webbrowser control on the middle of the form. that navigates to a Youtube video, the full screen button of the video doesn't work.
How can i get the fullscreen event (when triggered using html or flash)?
void MainFormLoad(object sender, EventArgs e){
this.KeyDown+= new KeyEventHandler(MainForm_KeyDown);}
void MainForm_KeyDown(object sender, KeyEventArgs e){
if( e.KeyCode == Keys.ControlKey)
MessageBox.Show("What is the Ctrl?");}
I am still shocked by how bad IE 11 shows web pages. So I strongly recommend using another engine like Chromium. View this post in order to know about library options.
I went with CefSharp and there is a great How To Guide in here But the browser lakes just full screens to form boundaries, so be noted in case using this option you might need to implement it yourself.
I am working at a problem in ASP.NET.
I have to create 2 windows (i think that I need to make web forms, i don't know why they said windows) one is the login form, when i press ok and the username and password is ok, I need to
show my second window (webform)
How can I do that?
I tried to do
protected void Button1_Click(object sender, EventArgs e)
{
Form2 form = new Form2();
form.SetFocus("id");
}
But it gives me error
A form tag with runat=server must exist on the Page to use SetFocus() or the Focus property.
What should I do?
Am i right, I have to do separate webforms for thoose windows?
This is the picture from the problem that they provided
If you use webforms you can just use the following code to redirect to second form:
protected void Button1_Click(object sender, EventArgs e)
{
Response.Redirect("Webform2.aspx");
}
I have a picture box in my application which displays pictures. Now if user clicks the picture/picture box then he should be redirected to the hyperlink given for that particular image in picturebox.
Is it possible? If yes, then how , if no then what would be an alternative?
I am using C# (Windows development)
Let me know for any inputs from my side
thanks
using System.Diagnostics;
private void pictureBox1_Click(object sender, EventArgs e)
{
Process.Start("http://www.stackoverflow.com/questions/5713934/give-url-to-picturebox");
}