string in table7.Rows[yy]["Die_ID"] in to a string array.how to solve this
string[] a = null;
if(table7.Columns.Contains(colx))
{
for (int yy=0; yy
double tval = double.Parse(table7.Rows[yy][colx].ToString());
if (tval < lower || tval > upper)
{
a[yy] = table7.Rows[yy]["Die_ID"].ToString();
//Error I want to store the string values in a string array :Object reference not set to an //instance of an object.
}
}
}

VulpesRank #55 · 29.2K reputationPosted Jun 1, 2014, 7:28 AM EDT
LegendItem firstItem = new LegendItem();
Font f = new Font("Georgia", 16);
foreach(string s in list)
{
LegendCell firstCell = new LegendCell(LegendCellType.Text, "Die_ID = _" + s, ContentAlignment.BottomCenter);
firstCell.Font = f;
firstItem.Cells.Add(firstCell);
}
Ranjit PowarRank #553 · 4.4K reputationPosted May 31, 2014, 9:20 PM EDT
VulpesRank #55 · 29.2K reputationPosted Jun 1, 2014, 12:39 AM EDT
Farhan ShariffRank #2,004 · 725 reputationPosted Jun 1, 2014, 1:55 AM EDT
I want to print this list/string array in legends (chart area), how to do that
something like
LegendItem firstItem = new LegendItem();
LegendCell firstcell = new LegendCell(LegendCellType.Text, "Die_ID = "_//print the list_foreach (int i in list) {+i.ToString() }, ContentAlignment.BottomCenter);
firstcell.Font = new Font("Georgia", 16);
Farhan ShariffRank #2,004 · 725 reputationPosted Jun 1, 2014, 8:27 AM EDT
ContentAlignment.BottomCenter);
foreach(string s in list)
{
LegendCell firstCell = new LegendCellType.Text, "Die_ID = _" + s, ContentAlignment.BottomCenter);
/*
.Text -System.Windows.Forms.DataVisualization.Charting.LegendCellType.Text' is a 'field' but is used like a 'type'
//Only assignment, call, increment, decrement, await, and new object expressions can be used as a statement*/'
firstcell.Font = f; //The name 'firstcell' does not exist in the current context
firstItem.Cells.Add(firstCell);
}
VulpesRank #55 · 29.2K reputationPosted Jun 1, 2014, 8:50 AM EDT
I've corrected it now :)
Farhan ShariffRank #2,004 · 725 reputationPosted Jun 1, 2014, 8:55 AM EDT
is there any other way to add the font
LegendItem firstItem = new LegendItem();
Font f = new Font("Georgia", 16);
foreach (string s in list)
{
LegendCell firstCell = new LegendCell(LegendCellType.Text, "Die_ID = _" + s, ContentAlignment.BottomCenter);
firstcell.Font = f;
firstItem.Cells.Add(firstCell);
}
Legend myLegend = new Legend("MainLegend");
myLegend.CustomItems.Add(firstItem);
chart1.Legends.Add(myLegend);
VulpesRank #55 · 29.2K reputationPosted Jun 1, 2014, 9:17 AM EDT
firstCell.Font = f;
Looking through the docs, I can't see another way to add the font. It seems you have to set each cell individually, though we're now using the same Font object for them all rather than creating a new object for each cell.
Farhan ShariffRank #2,004 · 725 reputationPosted Jun 1, 2014, 9:28 AM EDT
http://i.imgur.com/2lKnOGP.png
foreach(string s in list)
{
LegendCell firstCell = new LegendCell(LegendCellType.Text, "Die_ID = _" + s, ContentAlignment.BottomCenter);
firstCell.Font = f;
firstItem.Cells.Add(firstCell);
}
How to print these strings one after the other also some string is printed out of chart area I used +"\n" +"\r\n" Environment.NewLine
VulpesRank #55 · 29.2K reputationPosted Jun 2, 2014, 5:07 AM EDT
Farhan ShariffRank #2,004 · 725 reputationPosted Jun 2, 2014, 11:43 PM EDT
Instead of having a new line, it just added a space.
http://imgur.com/ZjPEhhb
VulpesRank #55 · 29.2K reputationPosted Jun 3, 2014, 5:02 AM EDT
I couldn't find anything in the docs for the LegendItem class, which is where I'd have expected it to be. However, the Legend class has a LegendStyle property which looks promising and I'd try setting this to LegendStyle.Column.
The Legend object to be used for this purpose is, of course, the one to whose CustomItems collection the current LegendItem is being added.
Farhan ShariffRank #2,004 · 725 reputationPosted Jun 3, 2014, 5:03 AM EDT
egendItem firstItem = new LegendItem();
VulpesRank #55 · 29.2K reputationPosted Jun 3, 2014, 5:13 AM EDT
Previously, we were adding a new LegendCell object for each element of the list and it may be that you're stuck with a horizontal arrangement if you do that.
Good thinking :)
Farhan ShariffRank #2,004 · 725 reputationPosted Jun 3, 2014, 5:16 AM EDT
Answer a question in the forums and earn +20 SHARP for every answer.
See unanswered questionsTop experts