Solved

Dynamically change NET4 Chart Title

Posted on 2014-04-28
2
1,543 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 500 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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Tool Box 2 35
Resolve Dependency Issues 4 48
Want to create a userform that looks like the image provided 10 46
ASP.net show message while code is running 3 11
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…
International Data Corporation (IDC) prognosticates that before the current the year gets over disbursing on IT framework products to be sent in cloud environs will be $37.1B.
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 a trusted technology advisor to your customers you are likely getting the daily question of, ‘should I put this in the cloud?’ As customer demands for cloud services increases, companies will see a shift from traditional buying patterns to new…

863 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

26 Experts available now in Live!

Get 1:1 Help Now