Click here to Skip to main content
15,879,535 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
I declared a string
string s = "Monthly Modeling"
I want this to display Bold format in the output..How to do?
thank u
Posted
Comments
Er Daljeet Singh 19-Nov-13 0:26am    
what you are using means you are using window application or a web application..
ahmed ali mohd 19-Nov-13 0:30am    
windows
ahmed ali mohd 19-Nov-13 0:33am    
see my code below

Set the necessary setting of the item you are using to display it. Eg: if displaying in a text box, set the text box property so that it's font is displayed in bold.
 
Share this answer
 
Comments
ahmed ali mohd 19-Nov-13 0:31am    
Im not using any controls..Iam displaying it in excel sheet..below is my code
WorksheetRow[] row = new WorksheetRow[Rep.Tables[0].Rows.Count];
WorksheetRow[] rowz = new WorksheetRow[3000];

for (int i = 0; i < Rep.Tables[0].Rows.Count; i++)
{
string str = "", s = "Monthly Modeling";
str=dt.Rows[i][0].ToString();
row[i] = sheet.Table.Rows.Add();
if (str != emp)
{
rowz[i] = sheet.Table.Rows.Add();
rowz[i].Cells.Add(s + str );//This will be displayed in excel,how to make it Bold???
row[i] = sheet.Table.Rows.Add();
}
Er Daljeet Singh 19-Nov-13 1:00am    
try to use this code ....
if (str != emp)
{
rowz[i] = sheet.Table.Rows.Add();
rowz[i].Cells.Add(s + str );//This will be displayed in excel,how to make it Bold???
using xl = Microsoft.Office.Interop.Excel;
xl.Range rng = (xl.Range)rowz[i];
rng.Font.Bold = true;
row[i] = sheet.Table.Rows.Add();
}
Er Daljeet Singh 19-Nov-13 1:00am    
in you for loop.
ahmed ali mohd 19-Nov-13 1:09am    
using xl = Microsoft.Office.Interop.Excel;

error:-office doesnt exist in microsoft
Er Daljeet Singh 19-Nov-13 1:19am    
you need add the reference of the Microsoft.Office.Interop.Excel.DLL reside inside the COM tab
if you are using a window application then you will use a label to display the text so simply set the Bold property of the label to true.

this.label1.Font = new System.Drawing.Font("Microsoft Sans Serif", 8.25F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((byte)(0)));


if you are using web application then simply append tag with your string like this

string s = "<b>Monthly Modeling</b>";
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900