如何使用工具栏中的保存按钮保存活动的richtextbox内容(Win Application) [英] How to use save button from toolbar to save active richtextbox content (Win Application)

查看:102
本文介绍了如何使用工具栏中的保存按钮保存活动的richtextbox内容(Win Application)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在我的应用程序中,我使用一个带有工具栏的主窗体。

和一个面板,我在其中加载不同的用户控件......

当我点击保存工具栏中的按钮如何检测当前用户控件和即时工作的选项卡?

i需要使用工具栏保存按钮保存richtext框文本!(我有多个选项卡)

In my application i use a main form which has a toolbar.
and a panel in which i load different user controls...
when i click on save button from toolbar how it will detect the current usercontrol and the tab on which i m working?
i need to save text of richtext box using toolbar save button!(i have multiple tabs)

推荐答案

查看 RichTextBox事件 [ ^ ]



GotFocus 事件就是您所需要的,但需要注意的是,当您从工具栏中单击保存按钮时,焦点将移动到此按钮。结论:您需要提供存储最后聚焦的RichTextBox信息的机制。
Have a look at the collection of RichTextBox events[^]

GotFocus event is that what you need, but you need to be warned that when you click save button from toolbar, focus will be moved to this button. Conclusion: you need to provide mechanism to store information about lastly focused RichTextBox.


class Active
    {
        private string localfname=string.Empty;
        private FastColoredTextBox localFctb;
        public Active()
        {

        }
        public string activeFile
        {
            get { return localfname; }
            set { localfname = value; }
        }
        public FastColoredTextBox activeFctb
        {
            get { return localFctb; }
            set { localFctb = value; }
        }
    }





1)将活动对象设置为另一个类作为属性。 />
2)每当按下工具栏按钮时,从活动类中获取活动对象。



1) "Set" active object to another class as a property.
2) "Get" active object from "Active Class" whenever toolbar button is pressed.


这篇关于如何使用工具栏中的保存按钮保存活动的richtextbox内容(Win Application)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆