Solved

Form Border Color

Posted on 2014-12-19
11
1,706 Views
Last Modified: 2015-01-07
Hi All,

I am developing a desktop application using C# windows application. I want to change the form border color with title change.

How can i achieve this?

Thanks in advance
0
Comment
Question by:Jatin Nahar
  • 4
  • 4
  • 3
11 Comments
 
LVL 33

Accepted Solution

by:
Mike Eghtebas earned 500 total points
Comment Utility
As shown in the attache image, Text property controls form caption.
On the form border experiment with different FormBorderStyle to see if any of them suits your need.
If you want have a red border, for example, you can use none for FormBorderStyle and then it will show no border but you can add a panel to it with silver background covering the form with red background showing only tiny bit like a border.FormTitleFormTitle2Now, you can add a label on to the panel to display title you want. There maybe a better ways to do this. But this is what I could think of.

Also, we can draw line via code which will be much cleaner and professional. We could do that as well.
0
 
LVL 33

Expert Comment

by:Mike Eghtebas
Comment Utility
This code draws a green line on the form border (with FormBorderStyle = none):
       private void Form1_Paint(object sender, PaintEventArgs e)
        {
            int width  =this.Width-1;
            int height = this.Height-1;
            Pen greenPen = new Pen(Color.FromArgb(255, 0, 255, 0), 5);
            e.Graphics.DrawRectangle(greenPen, 0, 0, width, height);
        }

Open in new window


Do not copy and paste this code in its entirety. First double click on paint event value box shown on the attached image. This will create the event and then copy and paste lines 3-6 into this event.
PaintEvent.bmp
0
 
LVL 62

Expert Comment

by:Fernando Soto
Comment Utility
Hi Jatin;

Since the form's border look is controlled by the operating system, and the currently selected theme this is not a simple task. There is a Windows Form extension that was created that will make this much simpler. Please have a look at this web site, Drawing Custom Borders in Windows Forms, at the bottom of that page there are three documentation links.
0
 

Author Comment

by:Jatin Nahar
Comment Utility
@Fernando: with your suggested solution, will i get the form text (main title)?
0
 
LVL 62

Expert Comment

by:Fernando Soto
Comment Utility
I have not used it myself but according to info on the website yes.
0
What Security Threats Are You Missing?

Enhance your security with threat intelligence from the web. Get trending threat insights on hackers, exploits, and suspicious IP addresses delivered to your inbox with our free Cyber Daily.

 

Author Comment

by:Jatin Nahar
Comment Utility
@Fernando: no with your solution the form main title will not appear. it will gone by using FormBorderStyle as none. And try the solution first at your end before giving it to someone else. Just googling won't solve the problem. Any one can do the googling.
0
 
LVL 33

Expert Comment

by:Mike Eghtebas
Comment Utility
Hi Jatin,

Fernando is a very caring expert, he often has gotten out of his way in helping me with my questions. I guess we always can appreciate his efforts. And, he is extremely knowledgeable.

Anybody can solve their problems and find their answers on their own but it takes longer; however, this goes much faster after connecting with the experts.  Here in EE community, experts help out in any way they could which is good.

Regards,

Mike
0
 
LVL 62

Expert Comment

by:Fernando Soto
Comment Utility
Hi Jatin;

Sorry that did not meet your needs. From within Visual Studio you can click on Tools -> Extensions and Updates. In the new window that is displayed click on the Online button on the left side and then in the search bar to right top  type in VisualStyler. Clicking on the download button on that product will bring up this page, VisualStyler for Windows Forms .NET, where you may download a trial version. The main site for the developer is SkinSoft where you can find the pricing plans.

Good luck.
0
 

Author Comment

by:Jatin Nahar
Comment Utility
Hi Fernado,

Thank you for your help. Is there any free third party tool for this work? Also is it possible without third party tool?
0
 
LVL 62

Expert Comment

by:Fernando Soto
Comment Utility
I personally do not have any knowledge or experience of a free library that can do what you need, sorry.
0
 

Author Closing Comment

by:Jatin Nahar
Comment Utility
excellent
0

Featured Post

How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

Join & Write a Comment

Suggested Solutions

Title # Comments Views Activity
Enable copy and pasting even when textbox is disabled 2 14
Long URL in SMS 6 21
Showdialog 8 20
Spacing between controls 4 15
More often than not, we developers are confronted with a need: a need to make some kind of magic happen via code. Whether it is for a client, for the boss, or for our own personal projects, the need must be satisfied. Most of the time, the Framework…
Wouldn’t it be nice if you could test whether an element is contained in an array by using a Contains method just like the one available on List objects? Wouldn’t it be good if you could write code like this? (CODE) In .NET 3.5, this is possible…
When you create an app prototype with Adobe XD, you can insert system screens -- sharing or Control Center, for example -- with just a few clicks. This video shows you how. You can take the full course on Experts Exchange at http://bit.ly/XDcourse.
This video explains how to create simple products associated to Magento configurable product and offers fast way of their generation with Store Manager for Magento tool.

728 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

8 Experts available now in Live!

Get 1:1 Help Now