IMPORTANT: this article is only relevant for Shape and Line controls generated by VB Migration Partner 1.33 or earlier versions.
Under VB6, Shape and Line controls are updated immediately after you change one of their properties. To optimize refresh operations and minimize flickering in converted VB.NET applications, however, changing a property of a Shape or Line control simply invalidates its container, so that all the Shape and Line controls it contains are updated at once as soon as the entire form is refreshed, which in turn happens when the application enters the idle state.
This behavior is fine in most circumstances, but at times you might want the Shape or Line control to be updated immediately. For example, you might be implementing a rubber-banding technique and you want immediate feedback, yet the VB.NET Line or Shape control would be drawn only when the user releases the mouse button and the when the application enters the idle state.
There are two ways you can achieve immediate redrawing with Line and Shape controls. The first technique requires that you just set the Line or Shape control’s ImmediateUpdate property to True. This property – which is exposed by the VB6Line and VB6Shape controls – determines what happens when a property of the control is changed. If its value is False (the default), the control’s container is invalidated and therefore it will be refreshed at the first occasion; if you set it to True, the container is refreshed immediately. Therefore, the simplest way to achieve immediate feedback is setting this property, either via code or at design time, for example by means of a WriteProperty pragma:
The problem with this approach is that it isn’t granular and in most cases it causes a lot of flickering, especially if you often modify many properties and if the container contains several Line and Shape controls. You can reduce such a flickering by leaving the ImmediateUpdate property to False and manually refreshing the containers after modifying a bunch of properties, as in this code:
Shape1.Left = Shape1.Left + 10
Shape1.Top = Shape1.Top + 10