Windows Form -- behavior of buttons? - windows

First time I've used the windows form so I'm not very familiar with the interface. But how do I set behaviors when I add buttons? For example, if I want to click "Button 1" and have it open up a new window to enter information in different fields, how is this done?
Thank you.
edit: Sorry, I forgot to include the language. It's in C#, and I'm using MS Visual Studios. I've never really programed in C#.
Another question that just popped up: could I do this Windows Form in other languages such as C++?

Yes the comment above is key but, if your are using the UI designer on a windows form then under the properties tab on the side of visueal studios, you can view 'events'. from here double click the event you want, probably 'onclick'. This will create a method stub with the event handler automatically set up.
Look something like:
public void Button1_OnClick(Object sender, EventArgs e){
// open the other window for input
Form whateverForm = new Form();
whateverForm.show();
}
Hope this helps. Sorry im not sure about any c++
[Edit]
tutorial not great but take a look:
http://www.ehow.com/how_7241167_tutorial-microsoft-visual-studio.html

Related

Xamarin.Forms/FreshMVVM - Yes/no style popup

This is probably a quite silly question, but it nonetheless needs an answer:
I have created a small, custom MessageBox for my Xamarin.Forms project using Rg.Plugins.Popup - however, when trying to extend it to include a confirmation modal, I cannot find a way to detect whether the user has confirmed or cancelled the action from the popup.
Here's the code to open the popup
Message msgBox = new Message(); /*new instance of my Message wrapper class*/
msgBox.State = "msg_info";
msgBox.MessageTitle = "My_Message_Title";
msgBox.MessageText = "My_Message_Caption";
await CoreMethods.PushPopupPageModel<MessageBoxPageModel>(msgBox); /*using the FreshMVVM.Popup extension to navigate to the popup*/
/*need to check for confirmation here and delete the line or do nothing*/
So what I'm looking for, in short, is the appropriate way to detect whether the user has tapped the "Yes" or "No" button on the popup so I can, for example, delete a row from my database or not.
I looked into MessagingCenter but that seems to work from ViewModel to View, not ViewModel to ViewModel - Rg.Plugins.Popup suggest using a CallbackEvent, but CallbackEvents are, or so I've understood, not compatible with FreshMVVM/the MVVM pattern.
Just so this isn't kept open:
I ended up using a DevExpress Popup control as a Yes/No dialog - slightly less customization, but much more straightforward to use since I already had the DevExpress controls loaded.
Detail link for the DevExpress Popup control for those interested
https://docs.devexpress.com/MobileControls/DevExpress.XamarinForms.Popup.DXPopup

How to make a button on a application open a register page in Visual Studio

I'm making an application group chat in Visual Studio learn a bit more, all is good so far, so I've made my design and coded most of what I need, I have added a Button and called it Register now what I want is when people click it it will open another page or some type of menu where people can type there information in to register, I thought somthing like this or is this so wrong.
private void RegisterButton_Click(object sender, RoutedEventArgs e)
{
//what gose here
}
You can use Response.Redirect inside the button click to do this.
Refer to these articles:-
https://msdn.microsoft.com/en-us/library/a8wa7sdt(v=vs.110).aspx
https://support.microsoft.com/en-sg/kb/307903

Simple yet important 4 questions about Visual Basic Studio 2012?

Guys I'm a student who knows simple stuff about Visual Basic Studio 2012 and who's working on creating an application for a course project. :)
I'm using ASP.Net Empty Website under Visual C#
If that makes sense. xD
Anyways, I have 4 important yet simple questions:
Q1: how do I apply Password Custom Vlaidation? For example 8 characters min in both the password and the password confirm text feild?
Q2: How do I apply "required" validation to a group of radio buttons, check boxes and a drop down list?
Q3: In a form, how do I get a list of radio buttons appear as options for once a customer picks a hair style category, however if she picks a make up categorty from the same drop down list, a whole different options appear? I hope it's clear lol
Q4: Is there a "range" tool in Visual Basic 2012 and how do I use it?
I appreciate every answer and so much thanks in advance. :D
For ASP.NET
Ans1:
Use RegularExpressionValidator instead of CustomValidator
Ans2:
Use RequiredFieldValidator with all the controls. And in the last use single ValidationSummary Control to display message. Here is link for you Understanding ASP.NET Validation Techniques
Ans3:
Use RadioButtonList control for options.
On SelectedIndexChange event of DropdownList control populate the RadioButtonList with relevant options.
Ans4:
Link in Ans2 will give you the RangeValidator control example.
I assume you are working in Winform.
And Since I am a C# developer I am posting my code in C#. you can use Telerik Code Converter to convert it to VB.NET
Ans1:
char[] charArray = s.ToCharArray();
int passwordCharacters = charArray.Length;
if (passwordCharacters < 8)
{
//Your code
}
Ans2:
Use ErrorProvider Control
Ans3:
There is no data bound RadioButtonList control in Winform. You will have to do it manually.
Ans4:
I don't think so there is any ASP.NET like Range Validator Control in VB.NET

Programmatically show the popup from a DatePicker

I'm using the DatePicker from the Silverlight Toolkit on Mango
I want to programmatically display the date picker full mode display, but I can't see any API hook to do that at the moment.
Is this possible? or do I have to implement this myself by (intelligently) writing a new control?
Build your own I'm afraid.
Be careful about the user expectations around opening it automatically though. ;)
Sadly Matt was right - there's no public or protected API to hack into and security prevents the use of Reflection - so I've +1'd his answer... and a full answer is:
take the files from Silverlight.codeplex.com
either use the whole project or create your own library with just DatePicker.cs, DateTimePickerBase.cs and the DatePicker Style template from Generic.xaml
in your DateTimePickerBase, add:
public event EventHandler<EventArgs> PopupClosedByDateSelection;
in ClosePickerPage() inside PopupClosedByDateSelection inside the if(_dateTimePickerPage.Value.HasValue) block, add:
if (PopupClosedByDateSelection != null)
PopupClosedByDateSelection(this, EventArgs.Empty);
This seems to work for the Back button case as well as for the cancel and OK cases.

lazarus gui main menu using forms?

i need to make a form where when a button is clicked then another form/page opens and from that for you can return to the original form in a similar fashion a main menu/sub menu works.
sorry im new to object pascal
Simply add the second form, and then in the button handler do a
secondform.showmodal;
Don't forget to add the unit where "Secondform" is in to the uses clauses of the first unit.
At the FreePascal Wiki you will find a tutorial on how to use Lazarus. You can read it in several different languages.
You can also see this Developing a GUI Application tutorial.

Resources