?
Solved

Dynamically change NET4 Chart Title

Posted on 2014-04-28
2
Medium Priority
?
2,010 Views
Last Modified: 2014-04-30
Hello Experts,

I have a net4 chart named chart_1.

I need vb code to  add title and sub title to chart_1

How do I
- specify the text
- center it
- font Ariel
- size 12
- Bold
- color black

I need code for both the title and the sub title (appears below title)

Thank you very much.

CGee
0
Comment
Question by:williecg
2 Comments
 
LVL 26

Accepted Solution

by:
Alan Warren earned 2000 total points
ID: 40029032
Hi CGee,

something like this oughta get you off in the right direction:
                ' not sure if titles collection is a zero based index 
                If Chart1.Titles(1) IsNot Nothing Then
                  ' specify the text
                  Chart1.Titles(1).Text = FormatDateTime(Date.Now, DateFormat.LongDate)
                  ' center it
                  Chart1.Titles(1).Alignment = Drawing.ContentAlignment.TopCenter
                  ' font Ariel, size 12, Bold
                  Chart1.Titles(1).Font = New System.Drawing.Font("Ariel", 12, Drawing.FontStyle.Bold, Chart1.Titles(1).Font.Unit)
                  ' color black
                  Chart1.Titles(1).ForeColor = Drawing.Color.Black
                  
                End If
                
                ' should be the same for subtitle except increment the index e.g., Chart1.Titles(2)

Open in new window

Respectfully yours,
Alan
0
 

Author Comment

by:williecg
ID: 40032981
Great, thanks so much, works great.  I had to add the title to the chart, then it work.

Chart_1.Titles.Add(0)
            Chart_1.Titles(0).Text = "Main Title"
            Chart_1.Titles(0).Alignment = Drawing.ContentAlignment.TopCenter
            Chart_1.Titles(0).Font = New System.Drawing.Font("Ariel", 12, Drawing.FontStyle.Bold, Chart_1.Titles(0).Font.Unit)
            Chart_1.Titles(0).ForeColor = Drawing.Color.Black

            Chart_1.Titles.Add(1)
            Chart_1.Titles(1).Text = "Subtitle"
            Chart_1.Titles(1).Alignment = Drawing.ContentAlignment.TopCenter
            Chart_1.Titles(1).Font = New System.Drawing.Font("Ariel", 8, Drawing.FontStyle.Bold, Chart_1.Titles(0).Font.Unit)
            Chart_1.Titles(1).ForeColor = Drawing.Color.Black
0

Featured Post

Free Tool: Site Down Detector

Helpful to verify reports of your own downtime, or to double check a downed website you are trying to access.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

ASP.Net to Oracle Connectivity Recently I had to develop an ASP.NET application connecting to an Oracle database.As I am doing it first time ,I had to solve several problems. This article will help to such developers  to develop an ASP.NET client…
User art_snob (http://www.experts-exchange.com/M_6114203.html) encountered strange behavior of Android Web browser on his Mobile Web site. It took a while to find the true cause. It happens so, that the Android Web browser (at least up to OS ver. 2.…
This is Part 3 in a 3-part series on Experts Exchange to discuss error handling in VBA code written for Excel. Part 1 of this series discussed basic error handling code using VBA. http://www.experts-exchange.com/videos/1478/Excel-Error-Handlin…
As many of you are aware about Scanpst.exe utility which is owned by Microsoft itself to repair inaccessible or damaged PST files, but the question is do you really think Scanpst.exe is capable to repair all sorts of PST related corruption issues?

750 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