|
What is the best approach for showing logged events and data in a window, both in situations where data will always be available a line at a time, and in situations where it won't?
One approach is to use a text box with the 'readonly' property enabled, and keep shoving new text at the end. That approach is workable, but the only practical methods of adding data are to either do something like "myTextBox.Text = myTextBox.Text & newStuff", which gets very slow pretty quickly, or else to set the selection point to the end of the text and then do "myTextBox.SelectedText = newStuff", which works better but trashes the positions of the current selection and scroll.
Another approach is to use a listbox. This offers some advantages, in that a listbox can perform well with lots of data, and an owner-draw listbox can display data in a variety of nice formats. Unfortunately, a listbox does not provide any good way for people to copy text, nor does it provide any nice way I can find to scroll when new data is added if and only if the scroll position is set to the bottom. Further, I'm not aware of any way to force a listbox to recalculate the height of all the objects therein (e.g. in response to a resize event) other than by deleting and re-adding all of them (which would be needlessly slow, would require extra handling to maintain anything even remotely resembling the current scroll position, etc.)
Are there any better alternatives to those types of controls?
|
|
|
|
|
|
I hadn't thought about it for this application. The one time I tried using a ListView, I found it confusing and couldn't figure out what was going on. It does conceptually seem like a ListView might be able to do what I'm after, but it also seems complicated. I don't care about people being able to edit stuff in the log window, but select/copy would be nice.
The ListBox is in some ways pretty good; the biggest weaknesses are:
(1) I don't know any reasonable way to have it reformat when the control width changes (to allow wordwrap). Not a biggie, and would probably be complicated to make work nicely.
(2) I don't know how to make scrolling behave sensibly (e.g. when a new item is added, scroll if the last item was visible but the new item is not; when items have to be pruned from the start of the box (e.g. keeping the last 10,000 lines) maintain the same apparent scroll position unless items on the display are getting deleted.
(3) I don't know any nice way to allow text select/copy. Right now I'm using double-click as a shortcut to copy a line to the clipboard, but that's nonstandard and seems ugly.
Of those, I'd say #2 is the only one that seems really bothersome. Any ideas how to deal with it?
|
|
|
|
|
i have a function with two parameters , I want to start the thread and want to give the address of that function in the thread.Now my question is how should i pass that function in thread.
According to my understanding , i should create a class , there i would create two variables of same type that of parameter list of function , and a function which contains that fucntion implementation .and now create an instance of the class and pass that address in the thread.
This seems to be a very lengthy process.
Please help.
Thanks
|
|
|
|
|
Nilish wrote: This seems to be a very lengthy process.
Well, if you can't be bothered writing 6 lines of code, perhaps you're in the wrong business.
Christian Graus
No longer a Microsoft MVP, but still happy to answer your questions.
|
|
|
|
|
what you did not like the answers you got last time clickety[^]
Never underestimate the power of human stupidity
RAH
|
|
|
|
|
I am using e.Graphics.DrawImage(pb.BackgroundImage,dPoints) to print the contents of a picture box. My problem is the picture box is set to use ImageLayout.Tile and I want the tiled image to print. However, what actually prints is the untiled source image, not the background as it appears on screen. Any help appreciated.
|
|
|
|
|
Is it possible to do a 'sticky' "VB FAQ" topic for questions that get asked several times per week. Stuff like: How do I convert this C# code to vb?
If certain FAQ are more in-depth, then simply provide links to the corresponding codeproject articles, msdn, etc.
On a day to day basis, there are alot of good questions and ideas; but there's also quite a few topics that get asked almost daily because users aren't using the search.
Just putting it out there as a suggestion.
Any suggestions, ideas, or 'constructive criticism' are always welcome.
|
|
|
|
|
FAQs have been written, and ignored, since this forum was created.
Christian Graus
No longer a Microsoft MVP, but still happy to answer your questions.
|
|
|
|
|
The good questions generally get answered and the dumb ones get dumped on, there have been a number of suggestions (including FAQs) to alleviated the issues but an idiot is an idiot and no matter what Chris tries will still post an idiot question before either searching or thinking.
You learn to take a small pleasure in dumping on the idiots or ignoring them. I do notice that the level of idiocy tends to fluctuate quite dramatically.
Never underestimate the power of human stupidity
RAH
|
|
|
|
|
Ahhahha..........now that's the best response I've read in a while!
Any suggestions, ideas, or 'constructive criticism' are always welcome.
|
|
|
|
|
Hi,
How can I addjust sharpening and contrast from a bitmap/image
Jan
I'm using VB.net 2008
I'm using u function like this:
Function Negatief(ByVal I As Bitmap) As Bitmap
Dim b As Bitmap = I.Clone
Dim clr As Color
For py As Integer = 0 To I.Height - 1
For px As Integer = 0 To I.Width - 1
clr = I.GetPixel(px, py)
b.SetPixel(px, py, _
Color.FromArgb(clr.A, clr.R Xor 255, clr.G Xor 255, clr.B Xor 255))
Next px
Next py
Return b
End Function
|
|
|
|
|
To sharpen an image you subtract part of the intensity from the surrounding pixels. To change the contrast you recalculate the intensity values to stretch the intensity curve.
There is some article here on cp about using a color matrix to modify images, which would work for changing contrast.
I have some code for sharpening lying around, that I thought that I would turn into an article some day...
Despite everything, the person most likely to be fooling you next is yourself.
|
|
|
|
|
U have said that you have an image sharpening code lying around!Would you mind if i see it because am working on an image sharpening form which uses track bar to show the effects of sharpening, step by step as you slide the bar.
So i do hope that code would help me kick off.
|
|
|
|
|
Hi Friends,
Pls. help me to send mail in vb.net 2005.
What is the requirements to send mail?
My OS are Win XP with SP2, No mail component(MS Outlook, Outlook express, etc) configure in my PC.
Give me example and requirement to send mail through vb.net 2005.
Thank you,
Chintu Shah
|
|
|
|
|
|
Thank you for immediate reply.
But that links example not work on VB.Net 2005.
|
|
|
|
|
Chintu Shah wrote: But that links example not work on VB.Net 2005.
Maybe not, but if you have any idea about VB.NET it should be easy enough to convert
There are loads of examples both here on CP and on Google, just use a little initiative.
Bob
Ashfield Consultants Ltd
|
|
|
|
|
The page is called "Visual Basic .NET Code Sample: Send Mail." Is there something I'm missing?
|
|
|
|
|
|
I wrote an article on how to use google here on CP. Sending email is both so trivial, and so widely documented, and yet a quesiton asked here so often, that I used it as an example, you should check it out.
Christian Graus
No longer a Microsoft MVP, but still happy to answer your questions.
|
|
|
|
|
Hi I hope this helps you out...here you are sending mail through exchange server.
This is is vb.net 2005
Public Sub psSendMail(ByVal sSubject As String, ByVal sBody As String)
Try
Dim EmailFrom As String = "SourceServer@Somewhere.com"
Dim EmailTo As String = "YourEmail@yahoo.com"
you can use either of these methods to connect to exchange server
'Dim EmailServer As New System.Net.Mail.SmtpClient("192.0.0.1")
Dim EmailServer As New System.Net.Mail.SmtpClient("emailservername.com")
Dim myMessage As New System.Net.Mail.MailMessage(EmailFrom, EmailTo, sSubject, sBody)
Try
EmailServer.Send(myMessage)
Catch
Finally
myMessage = Nothing
End Try
Catch ex As Exception
End Try
End Sub
|
|
|
|
|
hi friends,
I have made login form.After login when i logout then again Re-login that time without filling username and password show main form during clik on login button.
i want that when i logout then login form show with blank text boxes and when click on login button with blank textboxes gave message(fill text boxes)
Plz sort it out.
I am using following coding:
Code:
Try
conn.Open()
cmd = New SqlCommand("select * from usrs where uname = @user and upwd = @pwd", conn)
cmd.Parameters.AddWithValue("@user", Trim(TextBox1.Text))
cmd.Parameters.AddWithValue("@pwd", Trim(TextBox2.Text))
dr = cmd.ExecuteReader
While dr.Read()
a = dr.Item("upwd")
b = dr.Item("uname")
If TextBox1.Text = a And TextBox1.Text = b Then
sid = dr.Item("uid")
ProgressBar1.Visible = True
'Button1.Visible = False
'Button2.Visible = False
valid = True
Me.TextBox1.Clear()
Me.TextBox2.Clear()
End If
End While
dr.Close()
Catch ex As Exception
MsgBox(ex.Message)
Finally
conn.Close()
cmd = Nothing
End Try
modified on Wednesday, September 10, 2008 8:51 AM
|
|
|
|
|
I don't think there's any reason for If TextBox1.Text = a And TextBox1.Text = b Then . Of course they're going to be equal because that's what the query was to start with. (I assume you meant to say And TextBox2.Text = b instead of TextBox1 twice.)
If the username and password are shown in the textboxes when the form loads, clear the textboxes in Form_Load() .
|
|
|
|
|
Nothing happen:
Try
sUNAME = Trim(TextBox1.Text)
sPass = Trim(TextBox2.Text)
conn.Open()
cmd = New SqlCommand("select * from usrs where uname = @user and upwd = @pwd", conn)
cmd.Parameters.AddWithValue("@user", Trim(TextBox1.Text))
cmd.Parameters.AddWithValue("@pwd", Trim(TextBox2.Text))
dr = cmd.ExecuteReader
If dr.HasRows = 0 Then
MsgBox("Invalid User or Password, Try Again", vbCritical, "Login Error")
TextBox2.Clear()
TextBox1.SelectionStart = 0
TextBox1.SelectionLength = Len(TextBox1.Text)
TextBox1.Focus()
Exit Sub
Else
While dr.Read()
a = dr.Item("uname")
b = dr.Item("upwd")
If sUNAME = a And sPass = b Then
sid = dr.Item("uid")
ProgressBar1.Visible = True
valid = True
End If
End While
End If
dr.Close()
Catch ex As Exception
MsgBox(ex.Message)
Finally
conn.Close()
cmd = Nothing
End Try
form closing event:
sUNAME = String.Empty
sPass = String.Empty
|
|
|
|