C# Programming
09-02-2009, 01:30 PM
I need to "highlight" (e.g. make it bold) one word in a whole string used as a value in a cell. Is it possible?
I am using DataGridView, DataGridViewRow and DataGridViewTextBoxCell classes in my application.
Here is the snippet of the code:
DataGridViewRow aNewRow = null;
foreach (MatchData aMatchData in aSeasonData)
{
aNewRow = new DataGridViewRow();
DataGridViewTextBoxCell aCell = new DataGridViewTextBoxCell();
aCell.Value = aMatchData.Date;
aNewRow.Cells.Add(aCell);
aNewRow = new DataGridViewRow();
DataGridViewTextBoxCell aCell = new DataGridViewTextBoxCell();
aCell.Value = aMatchData.WhoPlaysWho;
aNewRow.Cells.Add(aCell);
aCell = new DataGridViewTextBoxCell();
aCell.Value = aMatchData.Result;
aNewRow.Cells.Add(aCell);
this.myListOfMatchesGridView.Rows.Add(aNewRow);
}
where myListOfMatchesGridView is of type DataGridView.
And according to the result stored in aMatchData.Result (e.g. 2:1 or 4:2) I need to make the winner team (stored in WhoPlaysWho) bold e.g. if the match was Legends vs. AllStars and the result was 3:1 for Legends the displayed output in the specific cell should be Legends vs. AllStars.
Please, give me a hint how to achieve this. From all I read about DataGrids I know how to change the font for the whole cell but so far I was not able to get an information how to change the font only for one word in a whole string (and use different font for the rest of the string) i.e. how to use two (or more) different fonts in one single cell.
I am using DataGridView, DataGridViewRow and DataGridViewTextBoxCell classes in my application.
Here is the snippet of the code:
DataGridViewRow aNewRow = null;
foreach (MatchData aMatchData in aSeasonData)
{
aNewRow = new DataGridViewRow();
DataGridViewTextBoxCell aCell = new DataGridViewTextBoxCell();
aCell.Value = aMatchData.Date;
aNewRow.Cells.Add(aCell);
aNewRow = new DataGridViewRow();
DataGridViewTextBoxCell aCell = new DataGridViewTextBoxCell();
aCell.Value = aMatchData.WhoPlaysWho;
aNewRow.Cells.Add(aCell);
aCell = new DataGridViewTextBoxCell();
aCell.Value = aMatchData.Result;
aNewRow.Cells.Add(aCell);
this.myListOfMatchesGridView.Rows.Add(aNewRow);
}
where myListOfMatchesGridView is of type DataGridView.
And according to the result stored in aMatchData.Result (e.g. 2:1 or 4:2) I need to make the winner team (stored in WhoPlaysWho) bold e.g. if the match was Legends vs. AllStars and the result was 3:1 for Legends the displayed output in the specific cell should be Legends vs. AllStars.
Please, give me a hint how to achieve this. From all I read about DataGrids I know how to change the font for the whole cell but so far I was not able to get an information how to change the font only for one word in a whole string (and use different font for the rest of the string) i.e. how to use two (or more) different fonts in one single cell.