文件管理 · 2022年8月3日

winform仿word|c#

Ⅰ C# WinForm开发 需要一个类似office 2007 菜单栏的控件

这个很简单。Ribbon界面效果,推荐使用DevExpress或者是DotNetBar。在CodeProject上有个RibbonPanel控件,也是可行的。

Ⅱ C#中winform能不能嵌套word程序

可以。前提是你的电脑里安装了Office,我用的是2003,那么在我电脑里就会有Office的COM组件。比如说我的Office2003就附带了MicrosoftWord11.0ObjectLibrary,引用进来就可以用了啊。还有,你在工具箱里点右键,然后选择“选择项”,在弹出的的对话框中选择COM组件,选择Office控件,添加进来。就可以像使用普通控件那样使用了。

Ⅲ c#,winForm嵌入word并能操作文档

在 Visual C# .NET 中新建一个 Windows 应用程序项目。默认情况下会创建 Form1。 在工具菜单上,单击自定义工具箱以打开自定义工具箱对话框。在 COM 组件选项卡上,添加一个对 Microsoft WebBrowser 的引用。单击确定,将 WebBrowser 控件添加到 Windows 窗体工具箱。WebBrowser 控件会显示出来,并且在工具箱中带有 Explorer(资源管理器)字样。 使用该工具箱向 Form1 添加一个 WebBrowser 控件、一个 OpenFileDialog 控件和一个 CommandButton 按钮。这就会向 Form1 类添加 AxWebBrowser1、OpenFileDialog1 和 Button1 成员变量。 在 Form1 上,双击 button1。这就会向 Form1 添加 Button1_Click 事件。 在 Form1 的代码窗口中,向列表添加以下命名空间:using System.Reflection; 如下所示在 Form1 类中定义一个私有成员:private Object oDocument; 在 Form1 类的 InitializeComponent 方法的末尾,添加以下代码以处理 Form1_Load、Form1_Closed 和 axWebBrowser1_NavigateComplete2 事件:this.axWebBrowser1.NavigateComplete2 += new AxSHDocVw.DWebBrowserEvents2_NavigateComplete2EventHandler(this.axWebBrowser1_NavigateComplete2); this.Load += new System.EventHandler(this.Form1_Load); this.Closed += new System.EventHandler(this.Form1_Closed); 将下面的代码private void button1_Click(object sender, System.EventArgs e) { } 替换为: private void button1_Click(object sender, System.EventArgs e) { String strFileName; //Find the Office document. openFileDialog1.FileName = ""; openFileDialog1.ShowDialog(); strFileName = openFileDialog1.FileName; //If the user does not cancel, open the document. if(strFileName.Length != 0) { Object refmissing = System.Reflection.Missing.Value; oDocument = null; axWebBrowser1.Navigate(strFileName, ref refmissing , ref refmissing , ref refmissing , ref refmissing); } } public void Form1_Load(object sender, System.EventArgs e) { button1.Text = "Browse"; openFileDialog1.Filter = "Office Documents(*.doc, *.xls, *.ppt)|*.doc;*.xls;*.ppt" ; openFileDialog1.FilterIndex = 1; } public void Form1_Closed(object sender, System.EventArgs e) { oDocument = null; } public void axWebBrowser1_NavigateComplete2(object sender, AxSHDocVw.DWebBrowserEvents2_NavigateComplete2Event e) { //Note: You can use the reference to the document object to // automate the document server. Object o = e.pDisp; oDocument = o.GetType().InvokeMember("Document",BindingFlags.GetProperty,null,o,null); Object oApplication = o.GetType().InvokeMember("Application",BindingFlags.GetProperty,null,oDocument,null); Object oName = o.GetType().InvokeMember("Name",BindingFlags.GetProperty ,null,oApplication,null); MessageBox.Show("File opened by: " + oName.ToString() ); } 按 F5 键运行该项目。单击浏览后,会出现打开对话框,您可以使用该对话框浏览到 Word 文档、Excel 工作表或 PowerPoint 演示文稿。选择任一文件,然后单击打开。文档在 WebBrowser 控件内打开,并出现一个显示有 Office 文档服务器名称的消息框。

Ⅳ 怎么用C#或WPF做一个类似Word的文字编辑器,可以实现自动生成新页,在线等高手

通过定义每页行数,然后判断最后页的行数是否超过呗~

Ⅳ 在winform中生成word,并在word里插入表格,表格第一列中的单元格里的文字竖向排列怎么设置

例如将上面竖排文字变为横排文字的方法:1、选中表格;2、单击表格工具布局—-文字方向按钮;3、设置后的效果如图所示。

Ⅵ 如何在C# winform中嵌入word文档

复制的,但是觉得在WebBroswer里面显示Word可行在 Visual C# .NET 中新建一个 Windows 应用程序项目。默认情况下会创建 Form1。 在工具菜单上,单击自定义工具箱以打开自定义工具箱对话框。在 COM 组件选项卡上,添加一个对 Microsoft WebBrowser 的引用。单击确定,将 WebBrowser 控件添加到 Windows 窗体工具箱。WebBrowser 控件会显示出来,并且在工具箱中带有 Explorer(资源管理器)字样。 使用该工具箱向 Form1 添加一个 WebBrowser 控件、一个 OpenFileDialog 控件和一个 CommandButton 按钮。这就会向 Form1 类添加 AxWebBrowser1、OpenFileDialog1 和 Button1 成员变量。 在 Form1 上,双击 button1。这就会向 Form1 添加 Button1_Click 事件。 在 Form1 的代码窗口中,向列表添加以下命名空间:using System.Reflection; 如下所示在 Form1 类中定义一个私有成员:private Object oDocument; 在 Form1 类的 InitializeComponent 方法的末尾,添加以下代码以处理 Form1_Load、Form1_Closed 和 axWebBrowser1_NavigateComplete2 事件:this.axWebBrowser1.NavigateComplete2 += new AxSHDocVw.DWebBrowserEvents2_NavigateComplete2EventHandler(this.axWebBrowser1_NavigateComplete2); this.Load += new System.EventHandler(this.Form1_Load); this.Closed += new System.EventHandler(this.Form1_Closed); 将下面的代码private void button1_Click(object sender, System.EventArgs e) { } 替换为: private void button1_Click(object sender, System.EventArgs e) { String strFileName; //Find the Office document. openFileDialog1.FileName = ""; openFileDialog1.ShowDialog(); strFileName = openFileDialog1.FileName; //If the user does not cancel, open the document. if(strFileName.Length != 0) { Object refmissing = System.Reflection.Missing.Value; oDocument = null; axWebBrowser1.Navigate(strFileName, ref refmissing , ref refmissing , ref refmissing , ref refmissing); } } public void Form1_Load(object sender, System.EventArgs e) { button1.Text = "Browse"; openFileDialog1.Filter = "Office Documents(*.doc, *.xls, *.ppt)|*.doc;*.xls;*.ppt" ; openFileDialog1.FilterIndex = 1; } public void Form1_Closed(object sender, System.EventArgs e) { oDocument = null; } public void axWebBrowser1_NavigateComplete2(object sender, AxSHDocVw.DWebBrowserEvents2_NavigateComplete2Event e) { //Note: You can use the reference to the document object to // automate the document server. Object o = e.pDisp; oDocument = o.GetType().InvokeMember("Document",BindingFlags.GetProperty,null,o,null); Object oApplication = o.GetType().InvokeMember("Application",BindingFlags.GetProperty,null,oDocument,null); Object oName = o.GetType().InvokeMember("Name",BindingFlags.GetProperty ,null,oApplication,null); MessageBox.Show("File opened by: " + oName.ToString() ); } 按 F5 键运行该项目。单击浏览后,会出现打开对话框,您可以使用该对话框浏览到 Word 文档、Excel 工作表或 PowerPoint 演示文稿。选择任一文件,然后单击打开。文档在 WebBrowser 控件内打开,并出现一个显示有 Office 文档服务器名称的消息框。

Ⅶ c# 仿word代码

网上有很多示例代码关于pageoffice,你参考看看。

Ⅷ winform实现word超链接怎么做,多谢指教

你可以用linkLabel来作为连接word的控件,在它的单击事件下: private void linkLabel1_LinkClicked(object sender, LinkLabelLinkClickedEventArgs e) { System.Diagnostics.Process.Start("e:\\工作注意事项.doc"); }运行后,单击就可以了啊

Ⅸ C#,WINFORM中如何实现类似WORD工具栏中选择颜色按钮的效果

private void Form1_Load(object sender, EventArgs e) { myComboBox.Items.Clear(); Array allColors = Enum.GetValues(typeof(KnownColor)); //获得系统颜色集合 foreach (KnownColor var in allColors) { myComboBox.Items.Add(var.ToString()); //加载该选项框的子项 } myComboBox.SelectedIndex = 1; } private void myComboBox_DrawItem(object sender, DrawItemEventArgs e) { //判断是否需要重绘 if (e.Index >= 0) { string colorName = myComboBox.Items[e.Index].ToString(); //子项的颜色名 SolidBrush brush = new SolidBrush(Color.FromName(colorName)); //画笔 Font font = new Font("宋体", 9); //字体样式 Brush brushs = Brushes.Black; Rectangle rect = e.Bounds; //获得需要重绘的区域 rect.Inflate(-2, -2); //缩放一定大小 Rectangle rectColor = new Rectangle(rect.Location,new Size(20,rect.Height)); e.Graphics.FillRectangle(brush, rectColor); // 填充颜色 e.Graphics.DrawRectangle(Pens.Black, rectColor); // 绘制边框 //绘制文字 e.Graphics.DrawString(colorName, font, brushs, (rect.X+22), rect.Y); } } 同时还需要设置该控件的DrawMode和DropDownStyle属性,类似的控件Listbox也可按同样方法实现颜色选择,DrawMode属性为NORMAL时,有选中效果,但自己绘制的选项则不会出现选中效果,若想实现,可在DrawItem中加入一个状态判定,如: //绘制选中效果 if ((e.State & DrawItemState.Selected) == DrawItemState.Selected) { SolidBrush brushItem = new SolidBrush(SystemColors.MenuHighlight); //画笔 Rectangle rectItem = e.Bounds; e.Graphics.FillRectangle(brushItem, rectItem); } else { SolidBrush brushItem = new SolidBrush(SystemColors.Window); //画笔 Rectangle rectItem = e.Bounds; e.Graphics.FillRectangle(brushItem, rectItem); }

Ⅹ winform 读取word跟直接打开word显示界面一模一样

客户不满意???抽Y的!叫他直接下载word就好了难道在开发一个word如果你打不过他,可以考虑,用模拟的方式上面写几个按钮,下面是个大文本框然后写文件流