Solved

Dynamically change NET4 Chart Title

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

Do You Know the 4 Main Threat Actor Types?

Do you know the main threat actor types? Most attackers fall into one of four categories, each with their own favored tactics, techniques, and procedures.

Join & Write a Comment

After several hours of googling I could not gather any information on this topic. There are several ways of controlling the USB port connected to any storage device. The best example of that is by changing the registry value of "HKEY_LOCAL_MACHINE\S…
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.
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…
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.

760 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

18 Experts available now in Live!

Get 1:1 Help Now