|
You may need to handle the control's paint event and draw it on top of the control.
Christian Graus
Driven to the arms of OSX by Vista.
Please read this[ ^] if you don't like the answer I gave to your question.
"! i don't exactly like or do programming and it only gives me a headache." - spotted in VB forums.
|
|
|
|
|
Thank you.
And do you have some suggestions of how this could be done?
I'm just looking for some guidance here.
Regards, Graham
|
|
|
|
|
Why not set the backcolour of the highlighted cells to a slightly brighter colour! That you can do un=sing the oncellpaint event.
Never underestimate the power of human stupidity
RAH
|
|
|
|
|
I'm using the BackColour Property for a different purpose.
Regards, Graham
|
|
|
|
|
My point still stands - if you are using red in the backcolour for highlighting a row then the cells in the block you want to highlight in that row get a slightly brighter red, the green row gets a brighter green. It may be better than having to manage the complete cell redraw to get a cell border.
Also you may want to look at Infragistics tools, one of my major complaints about their tools are the number of properties you can set on them, this may be a good thing for you.
Never underestimate the power of human stupidity
RAH
|
|
|
|
|
Thanks. I'll consider your suggestion for Plan B.
For now I'll keep looking and working on Plan A. It is more appropriate in the overall design.
Regards, Graham
|
|
|
|
|
Hi
Here is the code that I'm working on.
Imports System.Threading
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
tcpSend = New TcpSender
Dim trSend As New Thread(AddressOf tcpSend.RetrieveData)
trSend.Name = "Data Receiver"
tcpSend.Command = "Send data"
tcpSend.SysName = "Cabin1"
tcpSend.Port = 100
trSend.Start()
End Sub
Imports System.net
Imports System.Net.Sockets
Imports System.IO
Public Class TcpSender
Public Event SystemReplied(ByVal data As String)
Public Command, SysName As String, Port As Int16
Public Sub RetrieveData()
Try
Dim tcpCli As New TcpClient(SysName, Port)
Dim ns As NetworkStream = tcpCli.GetStream
Dim sw As New StreamWriter(ns)
Dim sr As New StreamReader(ns)
' Send data to the client.
sw.WriteLine(Command)
sw.Flush()
' Receive and display the response.
If Command = "Send data" Then
Dim strResult As String
'read the first line
strResult = sr.ReadLine & vbCrLf
If strResult <> "" Then
'reply has come from system so get the full data
For i As Byte = 0 To 2
strResult += sr.ReadLine & vbCrLf
Next i
RaiseEvent SystemReplied(strResult)
End If
End If
sr.Close()
sw.Close()
ns.Close()
Catch ex As Exception
'MsgBox(ex.Message)
End Try
End Sub
End Class
Private Sub SystemRepliedEventHandler(ByVal data As String) Handles tcpSend.SystemReplied
'MsgBox(data)
'create the controls to display data
'this doesn't work
Dim type As New TextBox
type.Location = New Point(100, 100)
type.Size = New Size(100, 100)
type.Text = data
Controls.Add(type)
End Sub
How to use control.invoke in the event handler. Any help would be appriciated much, as straighforwardly, I'm stuck here.
Thanks
reman
|
|
|
|
|
You must use Invoke to call a routine which will then be in the UI thread.
For example:
Dim dataStorage As String
Private Sub SystemRepliedEventHandler(ByVal data As String) Handles tcpSend.SystemReplied
dataStorage = data
Invoke(New MethodInvoker(AddressOf MyAddControl))
End Sub
Private Sub MyAddControl()
Dim type As New TextBox
type.Location = New Point(100, 100)
type.Size = New Size(100, 100)
type.Text = dataStorage
Controls.Add(type)
End Sub
You can think of a more elegant way of passing over data and such, but basically this is what you need.
It may be also interesting to consider the InvokeRequired method, which will return true if you are on a different thread than the UI. It can be useful when you need to know if you need to use Invoke . In your case it's perfectly safe to always use Invoke , but you can also change your code this way:
Private Sub SystemRepliedEventHandler(ByVal data As String) Handles tcpSend.SystemReplied
dataStorage = data
If (InvokeRequired) Then
Invoke(New MethodInvoker(AddressOf MyAddControl))
Else
MyAddControl()
End If
End Sub
Hope this will be of help.
2+2=5 for very large amounts of 2
(always loved that one hehe!)
|
|
|
|
|
You cannot create controls on a seperate thread. However, your thread code can Invoke a method on the UI thread that creates the controls for it.
|
|
|
|
|
Hello all
I want to loop images in my application when form loads it loads all the images and displays last image in picture box but i want to display all the images in picture box one by one i mean it starts from image 1 to image 15 and when it's image 15 it should start from image 1 again. this is what i have done
Private Sub Form1_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
Call LoadImages()
End Sub
Private Sub Timer1_Tick(ByVal sender As Object, ByVal e As System.EventArgs) Handles Timer1.Tick
For Me.I = 0 To 15
PictureBox1.Image = (MyImage(I))
Next I
End Sub
Private Sub LoadImages()
MyImage(0) = My.Resources.G1
MyImage(1) = My.Resources.G10
MyImage(2) = My.Resources.G11
MyImage(3) = My.Resources.G12
MyImage(4) = My.Resources.G13
MyImage(5) = My.Resources.G14
MyImage(6) = My.Resources.G15
MyImage(7) = My.Resources.G16
MyImage(8) = My.Resources.G2
MyImage(9) = My.Resources.G3
MyImage(10) = My.Resources.G4
MyImage(11) = My.Resources.G5
MyImage(12) = My.Resources.G6
MyImage(13) = My.Resources.G7
MyImage(14) = My.Resources.G8
MyImage(15) = My.Resources.G9
End Sub
it should keep displaying images until user close this application but image should be in right order according to myimage array
please help
|
|
|
|
|
Hi,
1) You load all images into an array (16 not 15 by the way).
2) When the timer event occurs you should load one image into the PictureBox.
What is your timer event handler doing?
Alan.
|
|
|
|
|
Hello
Thanks for your answer
you mean some thing like ths
Private Sub Timer1_Tick(ByVal sender As Object, ByVal e As System.EventArgs) Handles Timer1.Tick
For Me.I = 0 To 15
PictureBox1.Image = (MyImage(I))
Next I
End Sub
if yes then i have tried but still the same i know there is very small mistake but i am not getting there
|
|
|
|
|
Hi,
Every time the timer event fires you want to display a different image, correct?
Within your handler you have written a loop that loads all of the images every time it is called, hence you only ever see the last one, MyImage(15).
The code should select one index, i.e. one of the values 0 to 15, and then load the image referenced by the index into the picture box.
Alan.
|
|
|
|
|
Look at LoadImages. Assuming that you want the sequence to go in the order G1, G2, G3, G4, etc., you're setting the array in the wrong order. You load G10 before G2, and so on
Between the idea
And the reality
Between the motion
And the act
Falls the Shadow
|
|
|
|
|
hello
thanks for your rep.
no the order in array is right order so all the images should display as per array order what i what to do is when i start app it should display images until i close the app. i mean first image in array and then 2nd and 3rd up to 16th and then 1st image again but now it's load all the images and display only 16th image in to the picture box i want it keep displaying images from first image in array to last image in array and then go back to first image and so on
waiting for your kind help
|
|
|
|
|
Something like this?
Private Sub Timer1_Tick(ByVal sender As Object, ByVal e As System.EventArgs) Handles Timer1.Tick
Private Shared nextImage As Integer = 0
PictureBox1.Image = MyImage(nextImage)
nextImage = (nextImage + 1) Mod 16
End Sub
Regards
David R
---------------------------------------------------------------
"Every program eventually becomes rococo, and then rubble." - Alan Perlis
|
|
|
|
|
Unless I have misread your code, it would not work! Every time the tick event fires you are setting nextImage to 0, before doing anything else, therefore the last line of your snippet is useless.
The OP should use something like this:
Private Sub Timer1_Tick(ByVal sender As Object, ByVal e As System.EventArgs) Handles Timer1.Tick
PictureBox1.Image = MyImage(Me.I)
Me.I = (Me.I + 1) Mod 16
End Sub
Henry Minute
Do not read medical books! You could die of a misprint. - Mark Twain
Girl: (staring) "Why do you need an icy cucumber?"
“I want to report a fraud. The government is lying to us all.”
|
|
|
|
|
nextImage is static (i.e. Shared in VB) so it is set to 0 only on first call to Timer1_Tick. It retains its value between successive calls which is what I think the OP requires.
The problem with Me.I is it could be changed outside of the handler by some unrelated code. When the handler is called you have no idea what the value of Me.I is so it's wide open to index out of bounds exception.
Regards
David R
---------------------------------------------------------------
"Every program eventually becomes rococo, and then rubble." - Alan Perlis
|
|
|
|
|
OK. Sorry I missed that.
Henry Minute
Do not read medical books! You could die of a misprint. - Mark Twain
Girl: (staring) "Why do you need an icy cucumber?"
“I want to report a fraud. The government is lying to us all.”
|
|
|
|
|
Easily done - often guilty of it myself.
When I thought about the bounds it struck me that this is better.
Private Sub Timer1_Tick(ByVal sender As Object, ByVal e As System.EventArgs) Handles Timer1.Tick
Private Shared nextImage As Integer = 0
PictureBox1.Image = MyImage(nextImage)
nextImage = (nextImage + 1) Mod MyImage.Length
End Sub
Then you don't have to do anything if more images are added or some removed.
Regards
David R
---------------------------------------------------------------
"Every program eventually becomes rococo, and then rubble." - Alan Perlis
|
|
|
|
|
hello
thanks for your rep.
yes it's works fine
this is what i changed
Private Sub Timer1_Tick(ByVal sender As Object, ByVal e As System.EventArgs) Handles Timer1.Tick
'PictureBox1.Image = (MyImage(I))
Static nextImage As Integer = 0
PictureBox1.Image = MyImage(nextImage)
nextImage = (nextImage + 1) Mod MyImage.Length
End Sub
it's working as i was trying to
thanks a lot sir
have a nice day
|
|
|
|
|
riced wrote: Then you don't have to do anything if more images are added or some removed.
Good point.
I really should practice VB.Net more, if I want to play over here.
Henry Minute
Do not read medical books! You could die of a misprint. - Mark Twain
Girl: (staring) "Why do you need an icy cucumber?"
“I want to report a fraud. The government is lying to us all.”
|
|
|
|
|
Hi, I think this is the right place to post,
I've coded quite a bit in VB Net so far, not very advanced stuff though, and I'd like to learn more.
What I'd really like to do is create application that communicate over LAN, and to start of with something basic.
Like I click a button on one PC and in a texture on the other PC it says something like hello.
I've tried searhcing the internet, and I have no idea where to start. So I'm hoping someone here can help.
Evenutally I'd like to get a webpage that when you click a button on that it sends something (like 'hello') to a VB app.
Then get a VB app to talk to a Picaxe microcontroller, (I have already created an electronic dice using Picaxe and Basic(not VB))
I have created a website with the basics of html and php, and can do a little Javascript.
Then be able to send something(again like 'hello') from a webpage to a microcontroller (though VB or not).
I'm willing to learn, and this is something I'd really like to do, so please don't just discard this topic as another person just wanting code and not doing anything for it.
Thanks,
Jonathan
|
|
|
|
|
Unluckily, there is no easy and straight answer to what you ask. Inter-process commuications can be done in many different ways, all of which have their pros and cons, and all of which require study. Sending data from a "webpage" to an application can be even more complicated.
My best suggestion is you start having a Google at inter-process communications or tcp communications with VB.NET, and that might get you started for your first issue.
For the second issue, you need something more complicated, like SOAP or similar. If your website and the application reside on the same machine, then you might make it simpler by thinking about some kind of "local" inter-process communication between your server-side code (php or whatever) and the application.
I know I'm not of much help here, but it's really a wide subject we're talking about.
2+2=5 for very large amounts of 2
(always loved that one hehe!)
|
|
|
|
|
I believe the topic (technology) you are looking for would be considered a webservice. Do a search here in CodeProject and you should find something.
Maybe this article will help: (it is written in C#, but you should be able to get the idea)
How to make a simple WebService and consume it.[^]
|
|
|
|