Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8688093
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 12, 20262026-06-12T23:16:24+00:00 2026-06-12T23:16:24+00:00

How does one set the alignment of text within a chart legend object? I’ve

  • 0

How does one set the alignment of text within a chart legend object? I’ve tried using:

 myChartName.Legends["mySeriesName"].Alignment = stringAlignment.Near 

With no effect. I’ve also tried to create custom legend items, again resulting in no effect. Text is ALWAYS centered (along with the series marker) in the legend “box”. The only text I have been able to align is the title, but I don’t need titles in my application.

My research to date says the legend object is basically a table with (by default) two cells. If that is the case there should be a way to access those cells and manipulate them as table cells. So, what gives? Why can’t I access the text alignment properties of the legend object? Clearly, there is something I’m missing, but for the life of me I can’t seem to figure this out. Quite frustrating.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-12T23:16:26+00:00Added an answer on June 12, 2026 at 11:16 pm

    Problem solved. The CustomItem approach wasn’t working either, so I tried using the LegendCellColumn Class.

    I changed the LegendStyle from Column to Row, then added two CellColumns, one for the series symbol and one for the legend text. Set the alignment, margins, and column widths (that turned out to be the trick), and voila; a legend that looks like I want. Here’s the code for anyone with a similar issue.

    chartSel.Legends[ySeries.Name].CellColumns.Add(new LegendCellColumn("", LegendCellColumnType.SeriesSymbol, ""));
    chartSel.Legends[ySeries.Name].CellColumns[0].Alignment = ContentAlignment.TopLeft;
    chartSel.Legends[ySeries.Name].CellColumns[0].Margins = new System.Windows.Forms.DataVisualization.Charting.Margins(0, 0, 1, 1);
    chartSel.Legends[ySeries.Name].CellColumns[0].MinimumWidth = 250;
    chartSel.Legends[ySeries.Name].CellColumns[0].MaximumWidth = 250;
    
    chartSel.Legends[ySeries.Name].CellColumns.Add(new LegendCellColumn("", LegendCellColumnType.Text, ySeries.Name));
    chartSel.Legends[ySeries.Name].CellColumns[1].Alignment = ContentAlignment.MiddleLeft;
    chartSel.Legends[ySeries.Name].CellColumns[1].Margins = new System.Windows.Forms.DataVisualization.Charting.Margins(0, 0, 1, 1);
    chartSel.Legends[ySeries.Name].CellColumns[1].MinimumWidth = 1500;
    chartSel.Legends[ySeries.Name].CellColumns[1].MaximumWidth = 1500;
    

    It’s probably not the most efficient way to do it, but it works. Technically, the legend symbol and text are still centered in the object, but because I’m forcing the widths of the two columns it has the appearance of being left-justified.

    Hopefully, this may help another newbie like me avoid days of consternation.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

How does one build a function that can set an arbitrary value within a
How does one set the UITableView Section border color? I have tried and cant
How does one set a timeout on a BufferedReader and a PrintWriter created using
How does one set the date on the CalendarDatePicker. i.e. it defaults to current
How does one alternate row colors in a table in django that's generated using
How does one set the color of a line in matplotlib with scalar values
How does one set the maximum and minimum size of a window in OS
In c# how does one set the value of the AD property pwdLastSet This
How does one set the CSS background-image property to just load one particular icon
This question flows from the answer to: How does one set up multiple accounts

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.