IT Community - Software Programming, Web Development and Technical Support

Windows application questions

This is a discussion on Windows application questions within the C# Programming forums, part of the Software Development category; hi Anybody have idea in how to filter a particular values from a dataset in windows application..? How to filter ...


Go Back   IT Community - Software Programming, Web Development and Technical Support > Software Development > C# Programming

Register FAQ Members List Calendar Mark Forums Read
  #1 (permalink)  
Old 02-07-2008, 03:48 AM
Mramesh Mramesh is offline
D-Web Sr.Programmer
 
Join Date: Sep 2007
Location: Chennai
Posts: 106
Mramesh is on a distinguished road
Send a message via MSN to Mramesh
Default Windows application questions

hi

Anybody have idea in how to filter a particular values from a dataset in windows application..?

How to filter a particular values from a dataset in windows application,i.e,i have filled dataset from the table,now i want peoples age>25 and want to display that in grid.this should be done in windows application 2005...

Thanx in Advance...
Ramesh Kumar M

Last edited by Mramesh : 02-07-2008 at 03:55 AM.
Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
Sponsored Links
  #2 (permalink)  
Old 02-07-2008, 03:54 AM
Sundaram Sundaram is offline
D-Web Sr.Programmer
 
Join Date: Mar 2007
Location: chennai
Posts: 117
Sundaram is on a distinguished road
Send a message via MSN to Sundaram Send a message via Yahoo to Sundaram
Default Re: Windows application questions

hi ramesh,

Try to this way

Code:
ds.Tables("tablename").DefaultView.RowFilter = "age>25";
datagrid.datasource=ds;
datagrid.databind();
by
Sundaram.
Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #3 (permalink)  
Old 02-07-2008, 03:58 AM
a.deeban a.deeban is offline
D-Web Analyst
 
Join Date: May 2007
Posts: 279
a.deeban is on a distinguished road
Default Re: Windows application questions

hi ramesh,

use this sample code

Code:
dataview dv=ds.Tables("tablename").DefaultView
dv.rowfilter= "age>25";
datagrid.datasource=ds;
datagrid.databind();
by
Deeban..
Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #4 (permalink)  
Old 02-19-2008, 11:35 PM
Mramesh Mramesh is offline
D-Web Sr.Programmer
 
Join Date: Sep 2007
Location: Chennai
Posts: 106
Mramesh is on a distinguished road
Send a message via MSN to Mramesh
Default Re: Windows application questions

Deployment for DotNet applications (Windows Application)

.NET Classes used :

Create a windows application with the Name MyApplication and Build the application


Select Deployment project


1. On the File menu, point to Add Project, and choose New Project.

2. In the Add New Project dialog box, select Setup and Deployment Projects in the Project Types pane, and then choose Setup Project in the Templates pane. In the Name box, type MyApplication Installer.

3. Click OK to close the dialog box.

The project is added to Solution Explorer, and the File System Editor opens.

4. Select the MyApplication Installer project in Solution Explorer. In the Properties window, select the ProductName property and type MyApplication.

Note The ProductName property determines the name that will be displayed for the application in folder names and in the Add/Remove Programs dialog box.

Adding Windows application to the installer

1. Select the MyApplication Installer project in Solution Explorer. In the File System Editor, select the Application Folder node.

2. On the Action menu, choose Add, Project Output.

3. In the Add Project Output Group dialog box, choose MyApplication from the Project drop-down list. Click OK to close the dialog box.

4. Select the Primary Output group from the list, and then click OK.

5. On the Build menu, choose Build MyApplication Installer.
To deploy the application (basic installer)
this step can be skipped if you are following the complete walkthrough.

• Select the MyApplication Installer project in Solution Explorer. On the Project menu, choose Install.

This will run the installer and install MyApplication on your development computer.
Note you must have install permissions on the computer in order to run the installer.
Optional Deployment Capabilities

The remaining steps demonstrate optional deployment capabilities.
__________________
M.Ramesh Kumar
Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #5 (permalink)  
Old 02-19-2008, 11:37 PM
Mramesh Mramesh is offline
D-Web Sr.Programmer
 
Join Date: Sep 2007
Location: Chennai
Posts: 106
Mramesh is on a distinguished road
Send a message via MSN to Mramesh
Default Re: Windows application questions

Deployment for DotNet applications (Windows Application)

Shortcut Creation


This step creates a shortcut to your application that will be placed on the desktop of a target computer during installation.

To create shortcuts for the Windows application

1. Select the MyApplication Installer project in Solution Explorer.

2. In the File System Editor, select the Primary output from MyApplication node.

3. On the Action menu, choose Create Shortcut to Primary Output from MyApplication.

This will add a Shortcut to Primary output from MyApplication node.

4. Rename the shortcut Shortcut to MYAPPLICATION.

5. Select Shortcut to MYAPPLICATION and drag it to the User's Desktop folder in the left pane.

Creating a File Association

This step adds a file association for MyApplication so that double-clicking .fcs files will launch the MyApplication application.


To create file associations for the Windows application

1. Select the MyApplication Installer project in Solution Explorer. On the View menu, point to Editor, and choose File Types.

2. Select the File Types on Target Machine node in the File Types Editor. On the Action menu, choose Add File Type.

A New Document Type #1 node is added and opened for renaming.

3. Rename New Document Type #1 as Readme.txt.

4. In the Properties window, set the Extension property of the file type to fcs.

5. Select the Command property and click the Ellipsis ( ) button. In the Select item in project dialog box, navigate to the Application Folder, and select Primary output from MyApplication.

6. Click OK to close the dialog box.


Adding a Registry Entry

This step adds a registry key and value to the registry. You could reference this registry key from your application's code to retrieve per-user information at run time.

To add a registry entry for the Windows application

1. Select the MyApplication Installer project in Solution Explorer. On the View menu, point to Editor, and choose Registry.

2. Select the HKEY_CURRENT_USER node and expand it, then expand the Software node and select the [Manufacturer] node.
Note The Manufacturer node is surrounded by brackets to denote that it is a property. It will be replaced by the value entered for the Manufacturer property for the deployment project.

3. On the Action menu, choose New, Key.

4. Rename the key UserChoice.

5. Select the UserChoice key.

6. On the Action menu, point to New, then click String Value.

7. Rename the value TextColor.

8. In the Properties window, select the Value property and enter Black.


Custom Installation is one of the important area in Setup creation. Next Steps will explain the Custom Dialog Creation.


To add a custom installation dialog box
1. Select the MyApplication Installer project in Solution Explorer. On the View menu, point to Editor, and choose User Interface.

2. In the User Interface Editor, select the Start node under the Install node.

3. On the Action menu, choose Add Dialog.

4. In the Add Dialog box, choose Checkboxes (A).

5. Click OK to close the dialog box.

6. On the Action menu, choose Move Up twice to position the Checkboxes (A) dialog box above the Installation Folder dialog box.

7. In the Properties window, set the BannerText property to Samples.

8. Set the BodyText property to The Install Samples check box controls whether or not the sample files are installed. If left unselected, the samples will not be installed.

9. Set the CheckBox1Label property to install samples?

10. Set the properties Checkbox2Visible, Checkbox3Visible, and Checkbox4Visible to false. This will hide the additional check boxes.
__________________
M.Ramesh Kumar
Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #6 (permalink)  
Old 02-19-2008, 11:38 PM
Mramesh Mramesh is offline
D-Web Sr.Programmer
 
Join Date: Sep 2007
Location: Chennai
Posts: 106
Mramesh is on a distinguished road
Send a message via MSN to Mramesh
Default Re: Windows application questions

Deployment for DotNet applications (Windows Application)

Working with OptionFiles

This step creates a Samples subfolder that will be installed beneath the Application folder.
To add a OptionFiles folder

1. Select the MyApplication Installer project in Solution Explorer. On the View menu, point to Editor, and choose File System. The Application Folder should still be selected.

2. From the Action menu, point to Add, and choose Folder.

3. Rename "New Folder #1" as Samples.
This step creates two sample text files that will be installed if the user chooses the Install samples option in the custom dialog.


To create OptionFiles files for the application

Note To prevent MyApplication from automatically adding a .txt extension; choose All Files in the Files of type drop-down list.

1. Create text file containing the text this is Sample.fcs. Save it as sample.fcs.
This step adds the sample files to the OptionFiles folder, and sets a condition that determines whether to install the files.


To add the OptionFiles to the installer

1. Select the MyApplication Installer project in Solution Explorer. On the View menu, point to Editor, choose File System, and select the Samples folder.

2. From the Action menu, point to Add, and choose File. Add the Rules.vbn and sample.fcs files to the OptionFiles folder.

3. Select the file sample.fcs in the File System Editor.

4. In the Properties window, set the Condition property to CHECKBOXA1=1. When the installer is run, the file Memo.vbn will only be installed if the custom check box is selected.
Adding Launch Conditions


Checking IE 5.0 or later Version in Destination System

To add a launch condition to check the Internet Explorer version
Note this step is intended to demonstrate the concept of launch conditions; the MyApplication application has no actual dependency on Internet Explorer.

1. Select the MyApplication Installer project in Solution Explorer. On the View menu, point to Editor, and choose Launch Conditions.

2. In the Launch Conditions Editor, select the Requirements on Target Machine node.

3. On the Action menu, choose Add File Launch Condition.
A Search for File1 node is added beneath the Search Target Machine node, and a Condition1 node is added beneath the Launch Conditions node.

4. Rename Search for File1 to Search for Internet Explorer.

5. In the Properties window, set the FileName property to Iexplore.exe, the Folder property to [ProgramFilesFolder], the Depth property to 2, and the MinVersion property to 5.00.

6. Select the Condition1 node.

7. Set the Message property to this program requires Microsoft Internet Explorer 5.0 or higher. Please install Internet Explorer and rerun the MyApplication installer.


Additional Properties

This step sets a property to automatically install the Windows Installer bootstrapping application files if the correct version of Windows Installer is not present on the target computer.

To set optional properties for the deployment project

1. Select the MyApplication Installer project in Solution Explorer. On the View menu, choose Property Pages.

2. On the MyApplication Installer property page, select the Bootstrapper drop-down list, and choose Windows Installer Bootstrapper.

3. On the Build menu, choose Build MyApplication Installer.

Installing on Your Development Computer

This step will run the installer and install MyApplication on your development computer.

To install MyApplication on your development computer

• Select the MyApplication Installer project in Solution Explorer. On the Project menu, choose Install.
__________________
M.Ramesh Kumar
Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #7 (permalink)  
Old 02-19-2008, 11:44 PM
Mramesh Mramesh is offline
D-Web Sr.Programmer
 
Join Date: Sep 2007
Location: Chennai
Posts: 106
Mramesh is on a distinguished road
Send a message via MSN to Mramesh
Default Re: Windows application questions

Deployment Steps for Windows Application


Introduction

i want to explain some simple step for proper Deployment pakage preparaion

Types of Setup projects

• The Setup Project creates a Windows Installer project for a Windows-based application.
• The Web Setup Project creates a Windows Installer Web project to which files can be added manually during the development process.
• The Merge Module Project packages components that might be shared by multiple applications.
• The Setup Wizard assists developers step by step during the creation of a setup project.
• The Cab Project prepares a cabinet file for downloading to a legacy Web browser.

Steps for Windows Application

Take a Setup project from Visual Studio Deployment Projects. By default you will get.
File System on Target Machine
Different Editors in Setup project

1. File System on Target Machine.
2. Registry on Target Machine
3. File Types
4. User Interface
5. Custom Actions
6. Launch Conditions

In File System on Target Machine. We will find
Application Folder, Users Desk Top and Users Programs Menu

These all are General folders
Application Folder: This is where we need to copy all exe and dependencies of the application these will directly copied to Client machine Installation folder.
For adding application exe just right click on Application Folder area and Select Project Out put and for any Assemblies right click select Assembly it will show all Public Assemblies.
Users Desk top: In any Situation placing Short cuts or any files in Users Desk top Just drag file from Application Folder for placing Application short cut First select Application Project Output file in that right click for Options and Select Create Short cut Option it will create a short cut and Select Shortcut file and Set appropriate prop’s.
Users Programs Menu: This also place for adding Short cuts and read me files and Product documentations.

It has numerous special folders and a provision for adding User defined folders.

Registry on Target Machine:

In this it will show all Root Registry Key’s and it will provide a provision for adding a Key and Value at any place. This will add these keys in client machine directly.

File Types:

Use this editor to add file types and actions to apply to these file types, which are defined by their extension. For example, in the following figure, the file type FGG (with extension .fgg) that will have the action Open is defined.

User Interface:

Use this editor to tailor the appearance of the setup application. These settings can hide some screens from the setup wizard or can add more screens from a collection of template styles. In the following figure, you can see that it is possible to define which texts to show or specific parts of the wizard

Here Install and Administrative Install we need to set props for Install.
By default u will get Welcome, Installation Folder, Confirm Installation, progress, and Finish Screens.

Custom Actions:

Use this editor to specify which programs to execute when a specific action has been selected. This feature can be very useful to install further components or to create specific database objects. These actions can run under specific events, such as:
• Install the application
• Commit
• Rollback the installation
• Uninstall the application

Launch Conditions

Use this editor to specify which conditions to check on the target machine.

Validations can include file search, registry search, Component search or a particular deployment condition. Consider Display 4 where I added a Launch Condition and set the property condition as “PhysicalMemory>5000” i.e. 5GB and gave a custom error message “Physical Memory is less than 5GB.” After the build when I tried to install it gave me error message as shown in Display 5 and cancelled the installation process, obviously my system had less than 5GB HD space and condition evaluated to false.

Note: For List of properties available go to MSDN help and search on Property Reference. There is a launch condition “MsiNetAssemblySupport” by default. This can be removed if computer on which your application is being installed does not support CLR.

Some Important Props in Setup Project

After completion of the project preparation Select project and press F4 in the property window mainly set Manufacturer and Project name.

The one sticking point to all of this has been updating the installer version with each build. A Windows Installer MSI includes three GUIDs which identify the application being installed:
1. Upgrade Code - This identifies the application and should not change through it's lifetime
2. Package Code - This identifies a particular version of the MSI installer and should never be reused across builds. It must always be updated.
3. Product Code - This identifier is used to ID a particular version of the application. It is up to the installer author to decide when to assign a new product code. MSDN gives the example that in case where changes to the product are "relatively" minor; a new product code does not need to be assigned.
This tool can be used to update each of these values separately by passing it a GUID for the desired code. By default, it will generate a GUID to use for both the product and package values, and will not modify the upgrade value.




Files Created in Setup project
YourSetupProgram.msi
This file is the installer database required by Windows Installer to setup your application.
This file is the only one to distribute if the target system has Windows Installer already installed. However, it is recommended to distribute the entire set of files to make sure that the program can be installed if Windows Installer is not present.
InstmsiA.exe
This program installs Windows Installer in Windows 95/98/Me.
InstmsiW.exe
This program installs Windows Installer in Windows NT/2000/XP/.NET.
Note that Windows 2000, XP, and Microsoft Windows Server 2003 already include Windows Installer, but this distribution file might contain a newer version.
setup.exe
This application executes Windows Installer to install your application using the provided .msi file
This program checks that Windows Installer is available in the system, will install it if required, and then install the application.
Setup.ini
This file is the configuration file used by setup.exe to point to the .msi file


Summary

In this artile i tried to give steps to prepare a Setup Project .In this still remain lot options like preparing Custom actions and Launch condtions and userdefined User Interface. I will present it in very Soon
__________________
M.Ramesh Kumar
Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #8 (permalink)  
Old 02-19-2008, 11:51 PM
Mramesh Mramesh is offline
D-Web Sr.Programmer
 
Join Date: Sep 2007
Location: Chennai
Posts: 106
Mramesh is on a distinguished road
Send a message via MSN to Mramesh
Default Re: Windows application questions

Building Windows Application (Address Book) - Part I

In this section of article we will be seeing the development of the Login Form and some control in VB.NET

Building Windows Application (Address Book)

Building the User Interfaces

Initially lets build, some of the forms, then we will write the code to
implement various functionalities of the Address Book.

First lets start with building the Login Page of the Address Book.

Designing the Login Page.
When we talk about the login page, we should keep in minds the
following things.
  • It should ask for the user name and password
  • Where the password should be taken in the encrypted format.
  • Should have a Login and Cancel button,
    where On Clicking the Login should check for the existence
    of the user and log into the Address Book.
  • If the user clicks the cancel button, we should shut down the
    Address Book.
  • Form should not be resizable
  • Form should be in the screen center



Now Lets get into building a Login screen.

Before creating the form, we should create the project. Open the Visual
Studio.Net IDE and create a new project called "AddressBook".

Then Right click on the Project in the solution explorer and add a new
form called
FrmLogin.
__________________
M.Ramesh Kumar
Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #9 (permalink)  
Old 02-19-2008, 11:53 PM
Mramesh Mramesh is offline
D-Web Sr.Programmer
 
Join Date: Sep 2007
Location: Chennai
Posts: 106
Mramesh is on a distinguished road
Send a message via MSN to Mramesh
Default Re: Windows application questions

Note:

When developing an application we should follow the name conventions
strictly.

Some of the naming conventions that I am going to use through out the
project,

Form - Starts with Frm
Button - Starts with btn
Textbox - Starts with txt
Main Menu - Starts with mmnu
Context Menu - Starts with cmnu
Label - Starts with lbl
Panel - Starts with pnl
Link Label - Starts with lnk
Check box - Starts with chk
Radio Button - Starts with rdb
Group Box - Starts with grp
Data Grid - Starts with drd
Combo box - Starts with cbo
Timer - Starts with tim
Tool Tip - Starts with tlp
Error Provider - Starts with erp
Help Provider - Starts with hlp
Integer - starts with int
String - Starts with str

Apart from this, Each word in the Class names will begin in the Captial
Letter, for the object, variables and functions we will be using
capital letters for all the word in the name other than the first word.

We will not be having the underscore in names. All local variables will
begin with an under score (_).

Though VB.NET is not case sensitive, Lets try to follows these naming
conventions strictly. You may use your own style of code. But everywhere
you should follow the same naming conventions.
__________________
M.Ramesh Kumar
Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #10 (permalink)  
Old 02-19-2008, 11:59 PM
Sundaram Sundaram is offline
D-Web Sr.Programmer
 
Join Date: Mar 2007
Location: chennai
Posts: 117
Sundaram is on a distinguished road
Send a message via MSN to Sundaram Send a message via Yahoo to Sundaram
Question Re: Windows application questions

hi

Anybody have idea in How to send single value from one form to another in C# windows application..?

Thank you..
Sundram
Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #11 (permalink)  
Old 02-20-2008, 12:02 AM
Mramesh Mramesh is offline
D-Web Sr.Programmer
 
Join Date: Sep 2007
Location: Chennai
Posts: 106
Mramesh is on a distinguished road
Send a message via MSN to Mramesh
Default Re: Windows application questions

C# windows application sending data to another form on click event of button

.NET Classes used :
general classes

Introduction

Sending data to another form in C# application

Coding .....


Code for the value of one text box on form1 to another textbox on form 2


example:
:
There are 2 forms
form1 and form 2

Code:
onclick event of button1 on form1 write this code 
private void button1_click()
{
form2 xx=new form2();

//this will contain value of textbox1 on form1
//Tag value is int by default we have to convert into string 
xx.Tag=textBox1.Text;

xx.Show();
}


//now form2 coding 
private void form2_load()
{

//showing value of Textbox1 on form2 text box 

textBox2.Text=Convert.ToString(this.Tag);

}
__________________
M.Ramesh Kumar
Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #12 (permalink)  
Old 02-23-2008, 03:28 AM
Mramesh Mramesh is offline
D-Web Sr.Programmer
 
Join Date: Sep 2007
Location: Chennai
Posts: 106
Mramesh is on a distinguished road
Send a message via MSN to Mramesh
Default Re: Windows application questions (Exception classes)

Exception classes in .NET Framework

.NET Framework provides several classes to work with exceptions. When there is an exception, the .NET framework creates an object of type 'Exception' and 'throws' it. This Exception object contains all information about the 'error'.

If you enclose your code within the try-catch block, you will receive the exception object in the 'catch' block when the exception occurs. You can use this object to retrieve the information regarding the error and take appropriate action.

Code:
		try
		{
			// Code which can cause an exception.
		}
		catch(Exception ex)
		{
			// Code to handle exception
			MessageBox.Show ( ex.Message );
		}
Within the catch block, you can use the Exception object to get more information about the error. The exception object exposes a property called 'Message', which gives a description about the error. This may not be a very friendly message for the end user. But you can use it to log the error and show another friendly message to the user.
__________________
M.Ramesh Kumar
Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #13 (permalink)  
Old 02-23-2008, 03:30 AM
Mramesh Mramesh is offline
D-Web Sr.Programmer
 
Join Date: Sep 2007
Location: Chennai
Posts: 106
Mramesh is on a distinguished road
Send a message via MSN to Mramesh
Default Re: Windows application questions (Exception classes)

Exception classes in .NET Framework

The System.Exception class

In .NET, all exceptions are derived from the Exception class. The Exception class is defined inside the System namespace. Other derived exception classes are spread across many other namespaces.

Since all other exceptions are derived from the System.Exception class, if you catch System.Exception, that would cover all exceptions derived from System.Exception also. So, the statement catch (Exception) would catch all exceptions of type System.Exception and all derived exceptions. In .NET, all exceptions are derived from System.Exception. So, catch (Exception) will catch all posibble exceptions in your .NET application.

Specify what exception type you want to catch

See the catch block in the above sample code. catch ( Exception ex ) - specifies that we want to catch all exceptions of Type Exception. So, if there is an exception of Type Exception, it will be caught by the catch block.

If you specify an exception Type in the catch statement, it will catch all exceptions of the specified type and all types derived from it.

See the following sample :

Code:
try
		{
			// Code which can cause an exception.
		}
		catch(System.Web.HttpException ex)
		{
			// Code to handle exception
			MessageBox.Show ( ex.Message );
		}
The above example will only catch the exception of type System.Web.HttpException and any other exception derived from it. So, if there is any exception of type System.ArithmeticException, it will not be handled and it may lead to program termination.

Handling specific Exception types

In my previous article, I mentioned few examples from real life - "When you ride a bike, you may wear a helmet. When you go for boating, you might use a life jacket. A car driver might use seat belts while driving at high speed in a high way. What is the purpose ? To handle exceptions (accidents), right ? We do not know when it might happen, so we are prepared to 'handle' such situations any time. "

Yes, a helmet helps a bike rider when he meet with an accident. A life jacket may be helpful in water and a seat belt would help a car driver. But what if some one ride a bike with a helpmet, life jacket and a seat belt ? That may not look good, right ?

Similarly, in Exception handling, you do not need to catch all exceptions. You need to catch only the 'expected' exceptions. Which means, if you are doing an arithmetic calculation, you must handle ArithmeticException and DivideByZeroException. When you are accessing the web from your code, you must handle HttpException.

The bottom line is, depending on the nature of the code, you must handle the appropriate, specific exceptions, instead of catching the father of all exceptions (System.Exception).
__________________
M.Ramesh Kumar
Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #14 (permalink)  
Old 02-23-2008, 03:32 AM
Mramesh Mramesh is offline
D-Web Sr.Programmer
 
Join Date: Sep 2007
Location: Chennai
Posts: 106
Mramesh is on a distinguished road
Send a message via MSN to Mramesh
Default Re: Windows application questions (Exception classes)

Exception classes in .NET Framework
Multiple catch blocks

You can have any number of catch blocks for each try block. For example, if you are doing some operation which involve web access and also some arithmetic operations, you can handle both System.Web.HttpException and System.ArithmeticException. See the sample below:

Code:
try
		{
			// Code which can cause a web exception or arithmetic exception.
		}
		catch(System.Web.HttpException ex)
		{
			MessageBox.Show ( "A web exception occurred." );
		}
		catch(System.ArithmeticException ex)
		{
			MessageBox.Show ( "An arithmetic exception occurred." );
		}
Program Flow
When an exception occurs within a try block, the program control will jump to the first catch block and compare if the exception type is same the as the type specified in the catch block. If the type matches, it will execute the catch block. If the types do not match, it will jump to the next catch block and compare. Like this, it will compare against all catch blocks until a match is found. If there is no catch block found which matches the exception type, it will become an unhandled exception and will lead to program termination
__________________
M.Ramesh Kumar
Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #15 (permalink)  
Old 02-23-2008, 03:36 AM
Mramesh Mramesh is offline
D-Web Sr.Programmer
 
Join Date: Sep 2007
Location: Chennai
Posts: 106
Mramesh is on a distinguished road
Send a message via MSN to Mramesh
Default Re: Windows application questions (Exception classes)

Exception classes in .NET Framework

Catch derived exceptions first and base exception last

A base exception type will match the derived exceptions also. If there is a catch block with the type 'Exception', it will catch all types of exceptions. So, you have multiple catch blocks, you must specify the derived exception types first and the base types last. See the following code:
Code:
try
		{
			// Code which can cause a web exception or arithmetic exception.
		}
		catch (System.Exception ex)
		{
			MessageBox.Show ( "An exception occurred." );
		}
		catch (System.Web.HttpException ex)
		{
			MessageBox.Show ( "A web exception occurred." );
		}
In the above code, assume there is a web exception occurred. The exception type will be compared against the first catch block. Since the WebException is derived from System.Exception or oneof it's derived classes, the types will match and the first catch block will be executed. So, you might be expecting that the catch (System.Web.HttpException) block will be executed, but it would never get called because of the catch(System.Exception ex) before that.

You must change the above code as shown below :
Code:
try
		{
			// Code which can cause a web exception or arithmetic exception.
		}
		catch (System.Web.HttpException ex)
		{
			MessageBox.Show ( "A web exception occurred." );
		}
		catch(System.Exception ex)
		{
			MessageBox.Show ( "An exception occurred." );
		}
Now, if there is a web exception, it will go to the catch (System.Web.HttpException ex) block. All other exceptions will go to catch (System.Exception ex).
__________________
M.Ramesh Kumar
Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #16 (permalink)  
Old 02-23-2008, 03:40 AM
Mramesh Mramesh is offline
D-Web Sr.Programmer
 
Join Date: Sep 2007
Location: Chennai
Posts: 106
Mramesh is on a distinguished road
Send a message via MSN to Mramesh
Default Re: Windows application questions (sorting the columns in datagrid)

sorting the columns in datagrid - C # windows application 2005...

How to sort the columns in datagridview in c# windows application 2005."columns will be created automatically during the runtime,Could anyone send me the code..?


Thanx Advance
__________________
M.Ramesh Kumar
Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
Reply


Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Windows Forms Application Interview Tips and Tricks santhakumar Interview Questions & Answers and Tips 497 06-03-2008 08:50 PM
Application has failed to start because the application configuration is incorrect kingmaker ASP and ASP.NET Programming 5 01-03-2008 03:18 AM
How can i include Google Earth in my C# Windows application? a.deeban C# Programming 12 10-22-2007 05:51 AM
How can communicate between child and parent windows in VC++ win32 application? kingmaker C and C++ Programming 1 07-30-2007 12:51 AM
How to animate an image using C# windows application programmatically? mobilegeek C# Programming 1 07-30-2007 12:42 AM


All times are GMT -7. The time now is 01:22 PM.