两个问题
1.如何让label控件显示的时间与电脑的时间同步,不考虑用timer控件?
2.在richtextbox控件中如何打开word文档,并将word的内容在richtextbox中显示?

解决方案 »

  1.   

    1.Hook系统的时间消息(因该有这样的消息吧)。
    2.不知道
      

  2.   

    2.在richtextbox控件中如何打开word文档,并将word的内容在richtextbox中显示?
     
    public string[] getWords(string strFileName)
            {
                object missing = System.Reflection.Missing.Value;
                //Temporary cache to store words.
                string[] result = null;            //  Open a document.
                fileName = strFileName; //file name
                Microsoft.Office.Interop.Word.Application oWordApplic = null;
                Microsoft.Office.Interop.Word.Document oDoc = null;
                try
                {
                    oWordApplic = new Microsoft.Office.Interop.Word.Application();
                    oWordApplic.Visible = false;
                    oDoc = oWordApplic.Documents.Open(ref fileName, ref missing, ref readOnly, ref missing, ref missing, ref 
                        missing, ref missing, ref missing, ref missing, ref missing, ref missing, ref missing, ref missing, ref 
                        missing, ref missing, ref missing);                if (oDoc == null)
                    {
                        errMsg = "The file " + strFileName + " is null.";
                        return null;
                    }
                    //  Get words of a document,save them in a temporary array named result[].                oDoc.Activate();
                    //Get count of words.
                    int wordsCount = oDoc.Words.Count;
                    result = new string[wordsCount];
                    System.Collections.IEnumerator ieNum = oDoc.Words.GetEnumerator();                for (int i = 0; i < wordsCount; i++)
                    {
                        ieNum.MoveNext();
                        result[i] = ((Microsoft.Office.Interop.Word.Range)ieNum.Current).Text;                }            }
                //Capture exception when reading document.
                catch
                {
                    // ......
                }
            }//Add words to richtextbox  for(int i=0;i<result.Length;i++)
    {
      RichTextBox.text +=result[i];
    }
      

  3.   

    1.如何让label控件显示的时间与电脑的时间同步,不考虑用timer控件?
    为什么不使用timer呢??这个市最直接的方法。当然用线程也可以。不要以为多个线程系统会多点开销。这点开销根本忽略不计的