Solved

Dynamically change NET4 Chart Title

Posted on 2014-04-28
2
1,768 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
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

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

Whether you've completed a degree in computer sciences or you're a self-taught programmer, writing your first lines of code in the real world is always a challenge. Here are some of the most common pitfalls for new programmers.
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…
Michael from AdRem Software outlines event notifications and Automatic Corrective Actions in network monitoring. Automatic Corrective Actions are scripts, which can automatically run upon discovery of a certain undesirable condition in your network.…

707 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