名单在回答一个WinForm [英] List replies in a winform

查看:177
本文介绍了名单在回答一个WinForm的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在我的C#应用​​程序我得到一个包含一些答复就像在一个论坛主题服务器的XML(与笔者一样,时间,身体,title元素,等等)。

In my C# app I get an xml from a server that contains some replies like in a forum thread (with elements like author, time, body, title, whatever).

当我得到这个XML,我创建了一个新的形式,我想显示这些答复,并用添加回复按钮,一个小文本框。我也想对可能我的回答一些编辑按钮,在表单中显示的回答列表。

When I get this xml, I create a new form in which i want to display these replies, and a little text box with an "add reply" button. I'd also like some edit buttons on perhaps my own replies in the reply list displayed in the form.

这是来到我的脑海里显示的答复最简单的方法是把一个Web浏览器控件的形式,产生从XML字符串完整的HTML页面,并把它在Web浏览器控件。并根据它我可以把文本框具有附加的回复按钮。 一切正常,只是我不知道如何我可以实现编辑功能对我自己的回复(我的意思是我可以添加在里面的链接...但链接到什么)

The simplest way that came to my mind to display the replies is to put a web browser control in the form, generate a full html page in a string from the xml, and throw it in that web browser control. And under it i can put the text box with the add reply button. Everything is ok, except that i have no idea of how i could implement the edit function on my own replies (i mean i could add a link in there... but link to what)

我想知道是否有一种方式来获得从Web浏览器控件编辑事件(我的猜测是我不能)或其它(也许简单/简单)使用其他显示在一个WinForm的答复想法控制

I would like to know if there is a way to get that edit event from the web browser control (my guess is i can't) or another (maybe simple/easy) idea of displaying the replies in a winform using other controls

推荐答案

是的,这是可能的,你要打开设计模式上的文件。添加引用Microsoft.mshtml。启动一个新的Windows窗体项目拖放一个WB和窗体上的一个按钮。使code类似于此:

Yes, that's possible, you want to turn "design mode" on for the document. Add a reference to Microsoft.mshtml. Start a new Windows Forms project and drop a WB and a button on the form. Make the code look similar to this:

public partial class Form1 : Form {
    public Form1() {
        InitializeComponent();
        webBrowser1.DocumentText = "<html><body><textarea rows='15' cols='92' name='post-text' id='wmd-input'></textarea></body></html>";
        webBrowser1.DocumentCompleted += new WebBrowserDocumentCompletedEventHandler(webBrowser1_DocumentCompleted);
        button1.Click += button1_Click;
    }

    void webBrowser1_DocumentCompleted(object sender, WebBrowserDocumentCompletedEventArgs e) {
        mshtml.IHTMLDocument2 doc = webBrowser1.ActiveXInstance as mshtml.IHTMLDocument2;
        doc.designMode = "On";
    }

    private void button1_Click(object sender, EventArgs e) {
        var html = webBrowser1.Document.Body.All["post-text"].InnerHtml;
        // do something with that
        //...
    }
}

这篇关于名单在回答一个WinForm的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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