listview issues

M

Matt Michael

Hi,

I'm having a problem working with a listview in an application I'm writing.
Currently, whenever the selectedindex changed event fires, it loads up a
htmledit control, and other labels on the form, with the current information
associated with the listview item. Whenever I click on each item, it works
fine, but it seems that whenever I use the up/down arrows(important) to
scroll through the list, it loses focus, and goes to the htmledit control
whenever the index changes. Is there any way to make it so the listview
does not lose focus.. allowing the up and down arrows to work, all the while
refreshing the data on the form? Thanks in advance

-Matt

Sample code:

Private Sub lvMessages_SelectedIndexChanged(ByVal sender As System.Object,
ByVal e As System.EventArgs) Handles lvMessages.SelectedIndexChanged

If lvMessages.SelectedItems.Count > 0 Then
....get message..

If msg.Tables("Message").Rows.Count > 0 Then
...display fields
...enable appropriate buttons
deMessage.LoadDocument(body)
End If

Else
....empty message fields..
...disable buttons
End If
End Sub
 
O

One Handed Man \( OHM - Terry Burns \)

Just because it looses focus doesent mean it looses 'Selection', what
problem are you seeing ?

--

OHM ( Terry Burns )
. . . One-Handed-Man . . .

Time flies when you don't know what you're doing
 
M

Matt Michael

Whenever I use my down arrows or up arrows to move through the list, it will
move once. The html edit control will fill with the new data, and then any
attempt to use the down or up arrow to move to the next message results in
the scrolling of the html edit control. The block around the selection
turns grey, instead of blue like it should be.


-Matt
 
O

One Handed Man \( OHM - Terry Burns \)

Actually Matt, Im a little confused here regarding this HTML edit control
you are referring to. Is this a Web Project and you are referring to a multi
line textbox ? or is this a Windows Forms project and this is some 3rd Party
control ?

Actually, post your code as well

--

OHM ( Terry Burns )
. . . One-Handed-Man . . .

Time flies when you don't know what you're doing
 
M

Matt Michael

This is not a web project, but it's a control that allows display of HTML.
I'm getting the messagebody from a dataset, and using a string builder to
load
messageBody = Convert.ToString(msg.Tables("Message").Rows(0)("MessageBody"))

Dim sb As StringBuilder = New StringBuilder

Dim body As String
sb.Append("<html><head>")sb.Append("</head>")

sb.Append("<body>")

sb.Append(messageBody)

sb.Append("</body></html>")

body = sb.ToString

deMessage.LoadDocument(body)
 
M

Matt Michael

Sorry about the last message.. it wasn't complete (obviously). This is not
a web project, but it uses a control that allows display of html. The
control is displayed by issuing the LoadDocument method of the HTML control.
The messagebody is grabbed from a dataset and, used to display the document
in the HTML control. In the else clause, when the selectedItems < 0 the
EmptyMessageFields() simply builds a similar string, except it's a blank
document. The control is called HtmlEdit, but it references
Microsoft.mshtml.
messageBody = Convert.ToString(msg.Tables("Message").Rows(0)("MessageBody"))

Dim sb As StringBuilder = New StringBuilder

Dim body As String

sb.Append("<html><head>")

sb.Append("</head>")

sb.Append("<body>")

sb.Append(messageBody)

sb.Append("</body></html>")

body = sb.ToString

deMessage.LoadDocument(body)

The problem is that this control receives focus after I select a message,
and rather I would like to be able to scroll through the list without losing
focus with the down and up arrows.

Thanks



-Matt
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Similar Threads


Top