Jump to content
Xtreme .Net Talk

Recommended Posts

Posted

I have a simple Windows Form with several TextBoxes and Two buttons.

In the Load event, I change dynamically the text of the buttons and the caption text (depending of the user language)

To do that, I get an XML file and I retreieve the correct values.

 

For an unknown reason, my buttons are not painted (totally transparent) until I move to the next field.

I use the exactly the same technique for several different forms that are painted correctly.

No SuspendLayout or stuff like that...

 

So at the end of the form, I do a myButton1.Refresh and it is ok but it is really wierd.

 

Does someone has seen that ?

Any idea ?

Jarod
Posted

well...

here is a bitmap to show the result.

No buttons : after the load, as the forms is shown

With buttons : after a refresh (here I have minimized the form and restored it)

 

For the code, I just do somthing like that :

 Private Sub myBase_Load(ByVal sender As Object, ByVal e As EventArgs) Handles MyBase.Load
     DisplayLabels()
end sub

 Private Sub DisplayLabels()
'Get the XML string containing the labels
   Dim myLabelString As String = GetLabelsForContext("WIZARD"))
'labelExplorer is a Wrapper for navigating more easily in the XML,
'getting a PathNavigator, and exposing properties to get attribute from the XML
   Dim myLabelExplorer As New LabelExplorer(myLabelString)
   With myLabelExplorer
     While .MoveNext
       Select Case .TXT_CODE
          Case "txt0698" : DisplayLabel(btnCancel, .VALUE, .TOOLTIP, .HELP)
          Case "txt0699" : DisplayLabel(btnFinish, .VALUE, .TOOLTIP, .HELP)
'Do the same for other controls
       End Select
     End While
   End With
 End Sub

 Public Sub DisplayLabel(ByVal myControl As Control, ByVal value As String, _
                         ByVal tooltip As String, ByVal help As String)
   If Not myControl Is Nothing Then
     myControl.Text = value
     If Not tooltip Is Nothing Then
       ToolTip1.SetToolTip(myControl, tooltip)
     End If
     If Not help Is Nothing Then
       HelpProvider1.SetHelpString(myControl, help)
     End If
   End If
 End Sub

 

Btw, I use that kind of code for some other forms without any problem.

transparentbuttons.zip

Jarod

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...