选择列表框字符串到RichText框。 [英] Selected Listbox String to RichText Box.
问题描述
我正在创建一个使用电子邮件发送和接收短信的客户端。当我从服务器接收邮件进入我的列表框时,我只会遇到问题,但是如何选择列表框字符串,在richtextbox中打开邮件正文。这是我到目前为止的代码。
这里还有一张GUI图片,你可以更清楚地看到问题。
点击此处获取GUI图片
消息被放入收件箱我从列表框中选择时,只能在richtext框中显示消息正文。任何帮助将不胜感激!谢谢!
I am Creating a Client that uses email to send and recieve text messages. I only have to problems when i recieve the mail from the server it goes into my listbox but how do i make that listbox string, when selected, open the body of the message in a richtextbox. Here is my code so far.
Also here is a picture of the GUI so you can see the problem a little more clearly.
Click Here For GUI Picture
The messages are put into the Inbox i just cant display the body of the message in the richtext box when selected from the listbox. Any Help will be greatly appreciated! Thanks!
Private Sub Button2_Click(sender As Object, e As EventArgs) Handles Button2.Click
'variable declaration
Dim strMailServer, strUsername, strPassword, strFrom, strSubject, strToo, strBody, strMailContent As String
Dim popConn As Text_Me_Now.POP3
Dim mailMess As Text_Me_Now.EmailMessage
Dim intMessCnt, i As Integer
'set the variables to the input boxes
strMailServer = "pop.gmx.com"
strUsername = "xxxxxxx@gmx.com"
strPassword = "xxxxxxx"
'Disable the button when proccessing
Button2.Enabled = False
'create the objects
popConn = New Text_Me_Now.POP3
mailMess = New Text_Me_Now.EmailMessage
'if we have got to this point, try and connect to the server
popConn.POPConnect(strMailServer, strUsername, strPassword)
'now we have a connection, see if there are any mails on the server
intMessCnt = popConn.GetMailStat()
'now, see if we have returned any messages
If intMessCnt > 0 Then
'clear contents of the list and add the heading
ListBox1.Items.Clear()
'if we returned some messages, loop through each one and get the details
For i = 1 To intMessCnt
'load the entire content of the mail into a string
strMailContent = popConn.GetMailMessage(i)
'call the functions to get the various parts out of the email
strFrom = mailMess.ParseEmail(strMailContent, "From:")
strSubject = mailMess.ParseEmail(strMailContent, "Subject:")
strToo = mailMess.ParseEmail(strMailContent, "To:")
strBody = mailMess.ParseBody()
'add email details to the list box
ListBox1.Items.Add(strFrom & ", " & strSubject)
'un-comment to display full details of the email in a message box
'MsgBox("From: " & strFrom & vbNewLine & "Too: " & strToo & vbNewLine & "Subject: " & strSubject & _
'vbNewLine & "Body: " & strBody)
'call close method to delete the emails.
Next i
End If
'Quit the connection to the server
popConn.CloseConn()
Button2.Enabled = True
End Sub
Private Sub ListBox1_SelectedIndexChanged(sender As Object,
End Sub
推荐答案
代码给你......
对不起...没有空间..
这里下载代码
http://www.megafileupload.com/en/file/395411/CustomListItem-rar.html [ ^ ]
code for you...
Sorry ... not enaugh space..
download code here
http://www.megafileupload.com/en/file/395411/CustomListItem-rar.html[^]
e9net,有一个解决方案,但我想出了最简单的方法只需添加以下行...
e9net, had a solution but i figured out the easiest way to do it by simply adding the following lines...
Private Sub ListBox1_SelectedIndexChanged(sender As Object, e As EventArgs) Handles ListBox1.SelectedIndexChanged
RichTextBox1.Clear()
RichTextBox1.Text = ListBox1.SelectedItem
End Sub
代码和代码都少得多。谢谢你的帮助!
It was a lot less code and works. Thanks for your help though!
这篇关于选择列表框字符串到RichText框。的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!