.NET Tutorials, Forums, Interview Questions And Answers
Welcome :Guest
Sign In
Win Surprise Gifts!!!

Top 5 Contributors of the Month
Gaurav Pal
Post New Web Links

Form inheritance and key press event

Posted By:      Posted Date: October 05, 2010    Points: 0   Category :Windows Application


I've created a basic form BasicForm which all other forms in my application will inherit. In this basic form I'd like to handle some generic stuff which are common for all of the forms.  An example => key press event, for when user would press ESC key in any of my forms it would automatically close that form. This is how I tried to do it: 


public ref class BasicForm : public System::Windows::Forms::Form

 	protected: virtual void OnKeyPress(KeyPressEventArgs^ e) override
 		if (e->KeyChar == 0x1b ) // ESC

View Complete Post

More Related Resource Links

InfoPath Workflow Task Form "Loading" event handler only being called after App Pool recycled.


I have a Workflow that is using an InfoPath task form.  In the "FormEvents_Loading" method event handler I have some code that needs to run each time the form is opened.   I recycle the App Pool and open the form the code runs perfectly, but if I close and try to re-open the form the code is not run at all.  I can then recycle the App Pool again and on the next load the code executes just fine.   The code that is supposed to be run is a very simple statement to set a field value, so I don't think it is interfering.

Does anyone know what this might be?


OK button click on Windows dialogue form not triggering click event

I have created an Add-In for Outlook 2003 in Visual Studio 2005. When a new message is sent and a toggle button is selected, a form that I have created will be displayed as a dialogue box, where further information can be entered. Once this information has been entered you can click the OK button and the message is sent. If you were to click the OK button with invalid data in the form, there would be a message box with an error message. This all works perfectly on my development machine but when I have packaged the Add-In and installed it on other machines it does not work. Clicking on the OK button does nothing, there is not even an error message. All the prerequsits are successfully installed and this is the only part of the Add-In that does not work. All help greatly appreciated. Thanks Nick

Windows Keyup event is routed to next form even if the current form is closed

In a form (say FormA) i have 2 events "Keyup" for the form and button_click event for the button. I call FormA from the main form with a showDialog, after this i call another form (say FormB), it also has the 2 events. In both the form the button_click event has the logic to close the form (this.close()). Now when the FormA is opened the focus is on button, if the user presses "enter" button the button_click event is called which closes the form, the logic returns to the main form and the next line i.e. to open the FormB is executed. Now here is the wierd part, in FormB because there is a KeyUp event handler; just after instantiation of the form directly this event handler is called. I guess this is being routed from FormA. Shouldnt the FormA's keyup event be closed as soon as the form is closed?

text box key press event

Here's a portion of code that I have that takes the inputted text in a text box and sends it to a rich text box when the enter key is pressed:   private void textData_KeyPress(object sender, System.Windows.Forms.KeyPressEventArgs e) { if (e.KeyChar == 13 || textData.Text != null) { richMain.Text += ("\n" + textData.Text); textData.Text.Remove(0, textData.TextLength); } }   Could anyone tell me why this is not working?  Thanks in advance.

MdiChildActivate Form Closing Event

MdiChildActivate Event Occurs when a MDI child form is activated or closed within an MDI application.Is there anyway that we can find that the event is raised by the child form closing event?

opening a web browser without opening form on windows form load event

Hello All, I have a main frame which has a display button. after clicking on display button I usually open a windows forms. Now I have a requirement to open a web page after clicking on display button. I should not show windows form to the user. for that I had written following code in the Form_int (override) event of windows form. System.Diagnostics.Process.Start(http://www.google.com); and I commented out ShowDisplay(); code.  Everything looks good till now and when I run the project and clicked on display button web browser has been opened, but if I click again another web browser is being opening. but I don't want another browser to be opened. can anybody please help me in that. Thanks in advance.

event for minimized form

hi i need an event that fires when minimized form in taskbar is clicked. Any help would be greatly appreciated.

KeyDown event on a Form is not firing for STX and/or ETX

I'm using a wireless barcode reader that's inputting data using HID. I've configured it to wrap the output between STX and ETX (0x02, 0x03), however, i never get any KeyDown event generated when those keys are sent from the device, the barcode keys are sent just fine but not STX and ETX.

Web form page load event


I have  Web page that uses LinkButton control inside Template Fields of Gridview.

I am trying to work on LinkButton Click event and trying to preserve the Value of LinkButton that user click, and based on that value, i want to refresh tha page data.

I used CommandName and CommandArgument property of Linkbutton, but i can use that property only in GridView_RowCommand method by checking e.CommandName expression. But the problem with that Gridview_RowCommand event fire after all other page_load activity. So the value never used in the page_load event to refresh the data in all other control.

I also tried to use OnClick Method, Session variable and Hidden variable. but when i run Response.Redirect method from Gridview_RowCommand, it clear all the Session and Hidden variable values. also tried (Response.Redirect(,false)) method but never got success.

Any suggestion will be appricated in advance.

how can i load a window1.xaml form from click event fuction of a button

how can i load a window1.xaml form from click event fuction of a button

recurrence event functionality in custom new form



i am creating custom form for creating new Event( of Event List). How can i include reccurence event UI and functionlaity in my custom  form?


Thanks and Regards,


Form maximize/minimize click event


I need to know when the maximize or minimize button has been clicked. I am saving the window state so it is in the same state as when the user closed the app. Anyone know how to do this?




file attachment control on infopath 2010 browser form, validating event not fired


If preview within InfoPath 2010, the validating event is fired. But After deploying the form to SharePoint 2010, the validating event does not fire.

Any ideas?


Blog: http://convergingpoint.blogspot.com/

The paint event on form appears to be hijacking the thread in another form.


Hardware: GigaByte Motherboard with i5 4 core Processor

Development Software: VS 2008 Pro

Operating System: Windows 7 Pro

I have an application that displays five forms at start up.

  1. [Start ] about 300 PX wide opens all other forms on start.
  2. [Cluster ] has  a ListView, TelNet connection and a reference to a SerialPort Component on [Radio ].  This form has a mouse down event that populates and opens a dialog, [NewLogEntry ], which on load populates it's controls with data sent from [Cluster ].  [Cluster ] also writes data to [Radio ].SerialPort to set devices on [Radio ].  [NewLogEntry ] sends data to the data store and populates the ListView object on [Log ] before it closes.  [NewLogEntry ] also has a button containing the calculated bearing between the application users location and another point on the Earth.  Clicking that button writes the bearing to the reference that points to [Rotor ].SerialPort.  Upon closing [NewLogEntry ] sends it's data to the data store
  3. [Radio ] has many Buttons and a few GroupBoxes with a SerialPort Component connected to

[Pseudo]-Visual Form Inheritance in WPF...



I'm coming across from WinForms and need to understand how best to implement this requirement: [Pseudo]-Visual Form Inheritance in WPF. 

In my WinForms app (which I am sloooowly reengineering in WPF), I have lots of 'base' forms that set up certain requirements and generic functionality (such as ListFormBase, which has a data grid and several buttons. This base sets up lots of standard behaviours (CRUD, search, print, print preview, etc). The constructor accepts a generic parameter, which I use to pass in one of my business objects. 

In descendant forms, I simply add functionality that is specific/quirky to the individual business object (such as Product havingthe ability to search back orders, customer having the ability to pull up list of previous orders, etc.) All the standard behaviour comes down to the descendants automatically and new buttons/features are easy to add. This set up works an absolute treat - it's very simple, very effective.

I need to start to understand how to achieve the same in WPF. How do you create Pages in XAML that descend from base versions? How do I also link up the code behind in an OO manner, so that all the behaviour from the base comes down in the descendants? 

Any help would be much appreciated.


Simon Gol

ItemAdded Event not always returning SharePoint field information when InfoPath form submitted


 (SharePoint 2007)

I am struggling with an issue related to InfoPath and use of the ItemAdded event handler.  I have created an InfoPath form that contains several fields that are being published to SharePoint fields in a Forms Library.  When I submit a new form, the SharePoint data is being correctly updated.  ian see it in the list.  However, I am trying to write an ItemAdded event handler that performs specific logic based on the value of one of the InfoPath/SharePoint fields for the form being added to the library.  The logic appears to work correctly the first time through.  I can sucessfully read the value from the field and then execute my logic.  However, subsequent submissions appear to not be able to read the values.  It is like they don't exist or are null.  I am thinking that it has something to do with threading but I cannot find a work around for this problem.  The interesting thing is that the same exact logic works correctly when the ItemAdded event handler is tied to a standard Document Library.  Any word documents that are being added always read the values correctly. 


Does anybody know what might be causing this or a possible way around this issue? 



JQuery Validate plugin to validate a ASP.NET Form

The first time I used the JQuery Validate plugin, it did not work at all, see JQuery Validate odd behaviour with the ASP.NET Script Manager for reason, but perseverance and stubbornness prevailed and I finally created my first JQuery validated ASP.NET Forms contact form.
ASP.NetWindows Application  .NET Framework  C#  VB.Net  ADO.Net  
Sql Server  SharePoint  Silverlight  Others  All   

Hall of Fame    Twitter   Terms of Service    Privacy Policy    Contact Us    Archives   Tell A Friend