Checkbox Enabling [closed] - c#

Closed. This question is not reproducible or was caused by typos. It is not currently accepting answers.
This question was caused by a typo or a problem that can no longer be reproduced. While similar questions may be on-topic here, this one was resolved in a way less likely to help future readers.
Closed 1 year ago.
Improve this question
For Xamarin Forms:
I am looking to use checkboxes to enable the next set in a series. I have used x:name to set the names of the checkboxes (Fiore, Leichtenauer and Guards). My goal is to set a if statement to change the IsEnabled to false/true in the code behind when the first checkbox is checked. I seem to be getting an error for the IsEnabled, what should I be using instead? Thank you in advance.
private void CheckBox_CheckedChanged(object sender, CheckedChangedEventArgs e)
{
if (Fiore.IsChecked)
{
Leichtenauer = IsEnabled(false),
Guards = IsEnabled(true)
}
}

IsEnabled is a property of the control, so you would set it like
if (Fiore.IsChecked)
{
Leichtenauer.IsEnabled = false;
Guards.IsEnabled = true;
}

Related

c# Registry can't open Subkey with {} [closed]

Closed. This question is not reproducible or was caused by typos. It is not currently accepting answers.
This question was caused by a typo or a problem that can no longer be reproduced. While similar questions may be on-topic here, this one was resolved in a way less likely to help future readers.
Closed 11 months ago.
Improve this question
Here is my code
RegistryKey = regsohr;
regsohr = Registry.LocalMachine.OpenSubKey(#"HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows NT\CurrentVersion\Schedule\TaskCache\Tasks\{DFDC1B83-7FD3-4C77-8CD1-7391D1680ACA}");
sw.WriteLine(regsohr.GetValue("Path"));
It can't get into {DFDC1B83-7FD3-4C77-8CD1-7391D1680ACA}.
But when I delete that line everything works fine.
Anyone has any ideas why it can't open this SubKey?
I will appreciate any help.
My bad.
I have messed up with "HKEY_LOCAL_MACHINE".
regsohr = Registry.LocalMachine.OpenSubKey(#"HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows NT\CurrentVersion\Schedule\TaskCache\Tasks\{DFDC1B83-7FD3-4C77-8CD1-7391D1680ACA}");
Fixed it
regsohr = Registry.LocalMachine.OpenSubKey(#"SOFTWARE\Microsoft\Windows NT\CurrentVersion\Schedule\TaskCache\Tasks\{DFDC1B83-7FD3-4C77-8CD1-7391D1680ACA}");
Try this , for example i put it in a Label to check if it works
{
string readValue;
readValue = My.Computer.Registry.GetValue
(#"HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows NT\CurrentVersion\Schedule\TaskCache", "Tasks",Nothing);
Label6.Text = readValue;
}

how to solve the bool function that return one value in C# [closed]

Closed. This question is not reproducible or was caused by typos. It is not currently accepting answers.
This question was caused by a typo or a problem that can no longer be reproduced. While similar questions may be on-topic here, this one was resolved in a way less likely to help future readers.
Closed 1 year ago.
Improve this question
I have the following function:
public bool CheckConn()
{
try
{
if (JvarConn.State == ConnectionState.Closed)
{
JvarConn.Open();
return true;
}
}
catch
{
return false;
MessageBox.Show("No Connection");
}
}
but there is a red line error under the function name and the error is:
not all code paths return value
I tried to not putting a false value but the same error!. how can I solve that problem?
You can add return true;, just before the method closing bracket }. It’s giving error because what if it doesn’t meet the if.
Im returning true based on your method name declaration and implementation inside.

No events trigger and buttons are not pressable [closed]

Closed. This question is not reproducible or was caused by typos. It is not currently accepting answers.
This question was caused by a typo or a problem that can no longer be reproduced. While similar questions may be on-topic here, this one was resolved in a way less likely to help future readers.
Closed 3 years ago.
Improve this question
When creating a winforms application I added a pannel as a header so I could make the application borderless, I was going to add some buttons when I realised no events were getting registered by the program. Have I flicked a wrong switch somewhere?
I have already tried clicking the main form and changing the AutoValidation as well as checking that the form, as well as the panel, were both enabled.
public App()
{
InitializeComponent();
}
private void TopBar_MouseHover(object sender, EventArgs e)
{
Application.Exit();
}
private void ExitButton_Click(object sender, EventArgs e)
{
Application.Exit();
}
Expect result is that it should just close the application when I hover over the topbar or when I click the ExitButton.
I fixed this by going through the properties of the Forms/Buttons and resetting them as it turns out I had one item disabled.

navigation to the webpage was canceled webbrowser control c# [closed]

Closed. This question is not reproducible or was caused by typos. It is not currently accepting answers.
This question was caused by a typo or a problem that can no longer be reproduced. While similar questions may be on-topic here, this one was resolved in a way less likely to help future readers.
Closed 5 years ago.
Improve this question
i started a create a simple web browser...
when i code it web page is not loading...
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}
private void button1_Click(object sender, EventArgs e)
{
webBrowser1.Navigate("textBox1.Text");
}
}
}
This is the error when i go to a web page.
When you used the "" literals, you told the Compiler to treat what is between these "" as a literal string and not a valid C# expression. So the expression will not be evaluated. And your WebBrowser control will receive this literal string "textBox1.Text" exactly as it is. And not the Text property of textBox1 Control. By removing these "" literals:
webBrowser1.Navigate(textBox1.Text);
Your WebBrowser control will receive the value of Text property of the textBox1 control.
use webBrowser1.Navigate(textBox1.Text); instead

Accessing form's button field [closed]

Closed. This question is not reproducible or was caused by typos. It is not currently accepting answers.
This question was caused by a typo or a problem that can no longer be reproduced. While similar questions may be on-topic here, this one was resolved in a way less likely to help future readers.
Closed 5 years ago.
Improve this question
I have a button on my form, but I am unable to access it from my code. My code (from Program.cs):
Form1.button1.Text = "Button text"
I cannot access it due to it's protection level. What shall I do to change this field protection level or something?
On the properties window you can change the privacy of the components. You need to change the button privacy to public.
--EDIT
What fildor wrote is a better aproach
Changing the modifier of an object is a bad idea.
Better would be to create a public property on Form1, for example Button1Text and call that in stead of accesing a private object.
public string Button1Text
{
get { return Button1.Text; }
set {Button1.Text = value; }
}
then call it like this
form1.Button1Text = "I am a button"
Make sure that form1 is the created instance for your form, not the class name !

Categories