Disabling certain options in Visual Studio 2010, when one option is selected - visual-studio-2010

Hi guys Im using Visual Studio 2010 C sharp.
Basically Im building a program and I want to be able to disable certain options after one option is selected. For example when you fill out an online form for something like a job application and it asks do you have a degree? If you select no then the next options below related to the degree question are disabled. That is what I basically want to do.
I couldnt upload the image im affraid :(
Basically as you can see, what I want to do when RDP is selected the 'Site URL' becomes disabled but when any of the other web browser options are selected the 'RDP Connection' is disabled.
Thanks

Hi I figured out how to do this, I thought I would post it here in case it would be any help to anyone else/
Basically it was the use of just and if statement -_-" (cant believe I didnt think of it)
Basically below is a section of my script associated with the combo box I made. There are two options in the combo box, one if internet connection and one is RDP connection. When either one is selected it will 'hide' or 'show' certain data boxes below.
private void comboBox1_SelectedIndexChanged(object sender, EventArgs e)
{
if (comboBox1.Text == "Internet Browser")
{
label4.Visible = false;
comboBox2.Visible = false;
btnCreate.Visible = false;
label5.Visible = true;
textBox3.Visible = true;
}
else
{
label4.Visible = true;
comboBox2.Visible = true;
btnCreate.Visible = true;
label5.Visible = false;
textBox3.Visible = false;
}
}
Its basic boolean, if you have any problems, message me and I will help. Happy coding =)

Related

Telerik Winforms Reports freeze on Terminal Services

I am using Telerik reports in our app and it is being accessed mostly through an RDP session running in "app mode". Everything works fine locally but when I put it on the TS machine it freezes after the print dialog comes up.
The standard print dialog comes up and you can choose the printer and hit ok but then a small box opens with header of Printing... and then never does anything.
I am not sure what code to post since its fine locally, let me know what you want to see. also printing other things like the Telerik grids and charts are fine.
Found the answer on my own.
I created a standard printdialog screen and "rolled my own" print method and all seems to be good. Hope this helps someone else.
private void reportViewer1_Print(object sender, CancelEventArgs e)
{
this.Cursor = Cursors.WaitCursor;
e.Cancel = true;
try
{
PrintDialog pd = new PrintDialog();
pd.PrinterSettings = new System.Drawing.Printing.PrinterSettings();
var result = pd.ShowDialog();
if (result ==DialogResult.OK)
{
// Print the report using the custom print controller
var reportProcessor
= new Telerik.Reporting.Processing.ReportProcessor();
reportProcessor.PrintReport(this.reportViewer1.ReportSource, pd.PrinterSettings);
}
}
catch (Exception ex)
{
Program.ExceptionHandler(ex);
}
this.Cursor = Cursors.Default;
}

SelectedItem must always be set to a valid value. Windows Phone Local Database

I am using the local database example taht Microsoft created.
I can add items to the list, and delete them. But I now want to select the items and get the text of the item and use that in the next page.
This is the select changed event:
private void allToDoItemsListBox_SelectionChanged(object sender, SelectionChangedEventArgs e)
{
NavigationService.Navigate(new Uri("/LiveTimes.xaml?selectedItem=" + allToDoItemsListBox.SelectedIndex, UriKind.Relative));
// string urlWIthData = string.Format("/LiveTimes.xaml?name={0}", " ");
// this.NavigationService.Navigate(new Uri(urlWIthData, UriKind.Relative));
}
Then this is the on page load on the other page.
string selectedIndex = "";
if (NavigationContext.QueryString.TryGetValue("selectedItem", out selectedIndex))
{
int index = int.Parse(selectedIndex);
DataContext = App.ViewModel.HomeToDoItems[index];
}
Then when i use this, the error is on the DataContext line.
Whats the solution?
There is no problem in the above code that you have shown, The actual problem may be in the way how you defined your ViewModel and HomeToDoItems . It helps us to solve your problem, if you can show some of that code.
Also before setting your data to DataContext, try the following steps:
First, make sure you are getting the valid selectedIndex.
var tempData = App.ViewModel.HomeToDoItems[index];
DataContext = tempData;
And then insert a break point at tempData to check whether you are getting the expected data.
This answer may not solve your problem, but guide you in identifying the actual problem.

Internet lost connection Webbrowser

I have webrowser in app. I need to do something with webrowser when the internet connection is lost e.g. display MessageBox and when internet is again available reconnect to website. I find that can i use DeviceNetworkInformation.NetworkAvailabilityChanged Event, but when I 'm testing, the event is not firing.
I tried use DeviceNetworkInformation.IsNetworkAvailable, when navigating but this not have functionality that i want. I have testing in Nokia Lumia 710.
Here my simple code, i make him from example from msdn
http://msdn.microsoft.com/en-us/library/microsoft.phone.net.networkinformation.devicenetworkinformation.networkavailabilitychanged%28v=vs.92%29.aspx
DeviceNetworkInformation.NetworkAvailabilityChanged += new EventHandler(NetworkAvailabilityChanged);
void NetworkAvailabilityChanged(object sender, NetworkNotificationEventArgs e)
{
string info = string.Empty;
bool connection = false;
bool disco = false;
switch (e.NotificationType)
{
case NetworkNotificationType.InterfaceConnected:
connection = true;
break;
case NetworkNotificationType.InterfaceDisconnected:
info = "Lost Internet";
disco=true;
break;
case NetworkNotificationType.CharacteristicUpdate:
break;
default:
break;
}
Dispatcher.BeginInvoke(() =>
{
if(disco)
MessageBox.Show(info);
if(connection)
webbrowser1.Navigate(site);
});
}
I have question i check in phone that these methods IsCellularDataEnabled, IsNetworkAvailable, IsWiFiEnabled return true. I read somewhere that event NetworkAvailabilityChanged only work when is only one type of network is enable. Is this true?
Please check this page it may help you http://msdn.microsoft.com/en-us/library/microsoft.phone.net.networkinformation.devicenetworkinformation.networkavailabilitychanged(v=vs.92).aspx you can take the information of disconnected from NetworkNotificationEventArgs argument as it says...

How to show different pages when app launches time in windows phone 7?

When app launches time need to show the registration page.once user registered it shouldn't goes to registration page need to go log in page.
How to achieve this?
You can navigate to the start page of a Windows Phone app from code.
Remove the "DefaultTask" entry from the WMAppManifest
Remove the NavigationPage attribute from the "DefaultTask" in WMAppManifest, and in the Launching event of your app use the something like the example below to navigate to the page of choice upon launch.
private void Application_Launching(object sender, LaunchingEventArgs e)
{
if (registered)
{
((App)Application.Current).RootFrame.Navigate(new Uri("/<your start page>.xaml", UriKind.Relative));
}
else
{
((App)Application.Current).RootFrame.Navigate(new Uri("/<your registration page>.xaml", UriKind.Relative));
}
}
You just have to decide how you want to determine that someone already registered.
I guess you haven't put a lot of thought to this, the setup is pretty easy! When a user registers you could set a variable in the settings defining that a user already has registered. When the application starts, evaluate this setting and if the user registered you show the register-page, otherwise the login-page. Example:
//After (succesful) registration
Properties.Settings.Default.HasRegistered = true;
Properties.Settings.Default.Save();
//Check the value
var hasRegistered = Properties.Settings.Default.HasRegistered;
if(hasRegistered)
//show Login
else
//show Registration
You can also use the IsolatedStorageSettings.ApplcationSettings to do this. The code below is just sample code, you'll have to provide validation if the settings already exist on the first startup of the app and set a default value 'false' for the setting if no registration has occured yet.
//After registration
var settings = IsolatedStorageSettings.ApplicationSettings;
if (settings.Contains("HasRegistered"))
settings["HasRegistered"] = true;
settings.Save();
//Check value
var settings = IsolatedStorageSettings.ApplicationSettings;
if (settings.Contains("HasRegistered"))
{
var registered = bool.Parse(settings["HasRegistered"]);
if(registered)
//show login
else
//show registration
}
Hope this helps!

filesavedialog.showdialog hangs in windows 7

I am making custom setup project for msi.
There is very strange problem in one of the windows while installation goes. there is a show dialog call on click of a button. the installer is running fine on XP but on win 7 installer goes to not-responding and never comes back.
Below is the piece of code i am using for showing the dialog:
private void btnSetFileLocationWS_Click(object sender, EventArgs e)
{
saveFileDialog1.Title = "Set WS Log File Path";
saveFileDialog1.DefaultExt = "log";
saveFileDialog1.Filter = "Log files (*.log)|*.log|Text files (*.txt)|*.txt";
saveFileDialog1.FilterIndex = 0;
saveFileDialog1.RestoreDirectory = true;
if (saveFileDialog1.ShowDialog() == DialogResult.OK)
{
txtFilePathWS.Text = saveFileDialog1.FileName;
}
btnNextWSLogging.Enabled = EnableDisabledNextWSLoggingButton();
}
Anybody??
The MSI is running under an account which doesn't have access to the desktop. This thread suggests a possible workaround, setting AutoUpgradeEnabled to false.
To fix it properly, you need to set msidbCustomActionTypeNoImpersonate in your MSI, for which you will need to use the Orca MSI editor.

Resources