Thanks
naylynn
Posts
-
How to change Font in Word by C# -
How to change Font in Word by C#Hello Every Body!
I just try to text analysis program by C# .In the program i uses RichTextEdit . I want to load word file, text file , pdf to Richtext Edit Box. Now i can load these file to RichText Edit . But i can't change font these text. Just i used Microsoft.Office.Interop.Word; . Check my code below. Thanks for your kindness!public void ReadMsWord()
{
// variable to store file path
string filePath=null;
// open dialog box to select file
OpenFileDialog file= new OpenFileDialog();
// dilog box title name
file.Title="Word File";
// set initial directory of computer system
file.InitialDirectory= "c:\\";
// set restore directory
file.RestoreDirectory= true;
// execute if block when dialog result box click ok button
if (file.ShowDialog() ==DialogResult.OK)
{
// store selected file path
filePath=file.FileName.ToString();
}
try
{
// create word application
Microsoft.Office.Interop.Word.Application word =new Microsoft.Office.Interop.Word.Application();
// create object of missing value
object miss= System.Reflection.Missing.Value;
// create object of selected file path
object path=filePath;
// set file path mode
object readOnly= false;
//Microsoft.Office.Interop.Word.Font f = new Microsoft.Office.Interop.Word.Font();
//f.Name = "Zawgyi-One, 8.25pt";
//object fo = f;
// open document
Microsoft.Office.Interop.Word.Document docs=word.Documents.Open(ref path, ref miss, ref readOnly, ref miss, ref miss, ref miss, ref miss, ref miss,ref miss, ref miss, ref miss, ref miss, ref miss, ref miss, ref miss, ref miss);
// select whole data from active window document
docs.ActiveWindow.Selection.WholeStory();
// handover the data to cllipboard
docs.ActiveWindow.Selection.Copy();
// clipboard create reference of idataobject interface which transfer the data
IDataObject data= Clipboard.GetDataObject();
//Microsoft.Office.Interop.Word.Range rng = docs.Paragraphs[1].Range;
//rng.Font.Name = "Zawgyi-One";
//set data into richtextbox control in text format
richTextBox1.Text=data.GetData(DataFormats.Text).ToString();
//word.Selection.Font.Name = "Zawgyi-One";
// Microsoft.Office.Interop.Word.Document document = new Microsoft.Office.Interop.Word.Document();
// this.richTextBox1.SelectAll();
//System.Drawing.Font currentFont = richTextBox1.SelectionFont;
// richTextBox1.SelectionFont = new System.Drawing.Font(currentFont.FontFamily,currentFont.Size,newFontStyle);
// read bitmap image from clipboard with help of iddataobject interface
Image img= (Image)data.GetData(DataFor -
How to upload pdf file from sql to C#Thanks friend
-
datatype in DataGridviewhow to divided cell in Datagrid view. My code is don't work in fraction number. Someone advise me. Thanks you all.
foreach (DataGridViewRow row in this.dataGridView1.Rows)
{
int R1 = row.Index;
for (b = 0; b < dataGridView2.ColumnCount; b++)
{
a = 0;
for (c = 0; c < dataGridView2.RowCount; c++)
{
Ans_Grid.Rows[R1].Cells[b].Value =
(((Double.Parse(dataGridView1.Rows[R1].Cells[c].Value.ToString()))
* (Double.Parse(dataGridView2.Rows[c].Cells[b].Value.ToString())))).ToString()
;
Ans_Grid.Rows[R1].Cells[b].Value = a + Convert.ToInt16(Ans_Grid.Rows[R1].Cells[b].Value);
a = Convert.ToDouble(Ans_Grid.Rows[R1].Cells[b].Value); -
How to upload pdf file from sql to C#Thanks friend! I was thinking this way. But I have no idea "How do this method "Example--- How store pdf file to SQl.. and how retrieve pdf file to C#... You can teach me-- how write this
-
How to upload pdf file from sql to C#Hey Every Body! How do you do! I'm beginner of C# language. Now i want to save pdf file to sql and retrieve from there via C#. Someone could help me for this problem :) .. Thanks for every thing