IT Community - Software Programming, Web Development and Technical Support

Practical issues when we develop code in Windows Forms in C#.Net 2005

This is a discussion on Practical issues when we develop code in Windows Forms in C#.Net 2005 within the C# Programming forums, part of the Software Development category; Here,I would like to discuss the basic problems or issues that we face when we code in the Windows ...


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 09-20-2007, 05:10 AM
Sathish Kumar Sathish Kumar is offline
D-Web Analyst
 
Join Date: Feb 2007
Posts: 304
Sathish Kumar is on a distinguished road
Thumbs up Practical issues when we develop code in Windows Forms in C#.Net 2005

Here,I would like to discuss the basic problems or issues that we face when we code in the Windows Forms?
__________________
Sathish Kumar.R
Knowledge is meant to SHARE
Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
Sponsored Links
  #2 (permalink)  
Old 09-20-2007, 05:14 AM
a.deeban a.deeban is offline
D-Web Analyst
 
Join Date: May 2007
Posts: 279
a.deeban is on a distinguished road
Exclamation Re: Practical issues when we develop code in Windows Forms in C#.Net 2005

Hi Sathish,
This is a nice topic.Let me start with a question.How can I programmatically maximize or minimize a form?
Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #3 (permalink)  
Old 09-20-2007, 05:24 AM
Sathish Kumar Sathish Kumar is offline
D-Web Analyst
 
Join Date: Feb 2007
Posts: 304
Sathish Kumar is on a distinguished road
Thumbs up Re: Practical issues when we develop code in Windows Forms in C#.Net 2005

Hi Deeban,
Use the form's WindowState property for minimizing and maximising the forms.
//minimize
this.WindowState = System.Windows.Forms.FormWindowState.Minimized;

//maximize
this.WindowState = System.Windows.Forms.FormWindowState.Maximized;
__________________
Sathish Kumar.R
Knowledge is meant to SHARE
Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #4 (permalink)  
Old 09-20-2007, 05:46 AM
a.deeban a.deeban is offline
D-Web Analyst
 
Join Date: May 2007
Posts: 279
a.deeban is on a distinguished road
Exclamation Re: Practical issues when we develop code in Windows Forms in C#.Net 2005

Hi sathish,
Thats simple and superb.OK How can I display a interactive pop up when the user closes the form?
Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #5 (permalink)  
Old 09-20-2007, 05:50 AM
Sathish Kumar Sathish Kumar is offline
D-Web Analyst
 
Join Date: Feb 2007
Posts: 304
Sathish Kumar is on a distinguished road
Thumbs up Re: Practical issues when we develop code in Windows Forms in C#.Net 2005

Hi ,

You can listen to the Form's Closing event, where you can display a MessageBox as show below:

[C#]
private void Form1_Closing(object sender, System.ComponentModel.CancelEventArgs e)
{
if (MessageBox.Show("Do you want to close the application?", "Close Application", MessageBoxButtons.YesNo) == DialogResult.No)
e.Cancel = true;

}
[VB.NET]
Private Sub Form1_Closing(ByVal sender As Object, ByVal e As System.ComponentModel.CancelEventArgs)
If MessageBox.Show("Do you want to close the application?","Close Application",MessageBoxButtons.YesNo) = DialogResult.No Then
e.Cancel = True
End If

End Sub
__________________
Sathish Kumar.R
Knowledge is meant to SHARE
Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #6 (permalink)  
Old 09-20-2007, 05:53 AM
a.deeban a.deeban is offline
D-Web Analyst
 
Join Date: May 2007
Posts: 279
a.deeban is on a distinguished road
Exclamation Re: Practical issues when we develop code in Windows Forms in C#.Net 2005

Hi sathish,
You know the apearance of the form and controls plays a major role in the applications.So,I need to know How to center my form?Could anyone help?
Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #7 (permalink)  
Old 09-20-2007, 05:55 AM
Sathish Kumar Sathish Kumar is offline
D-Web Analyst
 
Join Date: Feb 2007
Posts: 304
Sathish Kumar is on a distinguished road
Thumbs up Re: Practical issues when we develop code in Windows Forms in C#.Net 2005

Hi Deeban,
Yes.You are absolutely right.You can set the Form's StartPosition property to CenterScreen to achieve this.
__________________
Sathish Kumar.R
Knowledge is meant to SHARE
Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #8 (permalink)  
Old 09-20-2007, 06:00 AM
a.deeban a.deeban is offline
D-Web Analyst
 
Join Date: May 2007
Posts: 279
a.deeban is on a distinguished road
Exclamation Re: Practical issues when we develop code in Windows Forms in C#.Net 2005

Hi sathish,
I tried your idea.Its working.Now I am overcoming another doubt.When we resize the form,the whole arrangement of controls gets collapsed.So,I dont want to allow users from resizing my forms.Do you have any idea how to do this?
Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #9 (permalink)  
Old 09-20-2007, 06:36 AM
Sathish Kumar Sathish Kumar is offline
D-Web Analyst
 
Join Date: Feb 2007
Posts: 304
Sathish Kumar is on a distinguished road
Thumbs up Re: Practical issues when we develop code in Windows Forms in C#.Net 2005

Hi Deeban,
You can prevent the users from resizing your form by setting the FormBorderStyle to FixedDialog and setting the MaximizeBox property to false.
__________________
Sathish Kumar.R
Knowledge is meant to SHARE
Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #10 (permalink)  
Old 09-20-2007, 07:14 AM
a.deeban a.deeban is offline
D-Web Analyst
 
Join Date: May 2007
Posts: 279
a.deeban is on a distinguished road
Exclamation Re: Practical issues when we develop code in Windows Forms in C#.Net 2005

Hi Sathish,
I am a newbie.And the first thing that strikes me to learn the display and appearance of the application.Thats why I am asking a lot of questions on this one.ok How do I programmatically set an image as Form's Icon ?
Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #11 (permalink)  
Old 09-20-2007, 07:17 AM
Sathish Kumar Sathish Kumar is offline
D-Web Analyst
 
Join Date: Feb 2007
Posts: 304
Sathish Kumar is on a distinguished road
Thumbs up Re: Practical issues when we develop code in Windows Forms in C#.Net 2005

Hi Deeban,
You could do so as shown in the code below :
[C#]
Form form1 = new Form();
Bitmap bmp = imageList1.Images[index] as Bitmap;
form1.Icon = Icon.FromHandle(bmp.GetHicon());

[VB.NET]
Dim form1 As Form = New Form()
Dim bmp As Bitmap = imageList1.Images(index) as Bitmap
form1.Icon = Icon.FromHandle(bmp.GetHicon())
__________________
Sathish Kumar.R
Knowledge is meant to SHARE
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
SQL 2005 Installation issues Error (0xc0000005). nnraja Server Management 2 10-29-2007 01:05 AM
Windows Forms Patterns Mramesh C# Programming 0 09-25-2007 09:13 AM
Windows Forms from MFC Sundaram C# Programming 5 09-25-2007 09:09 AM
Windows Forms Mouse Handling Sundaram C# Programming 3 09-25-2007 08:51 AM
Pratical issues in adding controls to Windows Forms in C#.Net 2005 Sathish Kumar C# Programming 21 09-22-2007 05:11 AM


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


Copyright ©2004 - 2007, DiscussWeb. All Rights Reserved.

SEO by vBSEO 3.0.0