• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 258
  • Last Modified:

language msgbox

how do i set a messagebox depending on the user's language ?

I want to use a Y/N msgbox in french



thank you.
0
TheSonics
Asked:
TheSonics
  • 2
  • 2
2 Solutions
 
ZeonFlashCommented:
I don't believe that you can control that on the msgbox's.  The language that is displayed is pulled from the system language, so you would have to have your entire system set to display the French language.  Is this the only place in your application that you wish to use a different language?  You might want to also consider just creating your own CustomMsgBox class that you can use in place of the built-in MsgBox.
0
 
TheSonicsAuthor Commented:
sounsd good i have to derivate a class or do my own form ?
0
 
ZeonFlashCommented:
You can just create your own form.  You can pass in the message text (and even the button type/text, if you want to extend the form's usage).  Something like this:

Public Class CustomMsgBox
      Inherits System.Windows.Forms.Form

#Region " Windows Form Designer generated code "

      Public Sub New(ByVal MessageString As String)
            MyBase.New()

            'This call is required by the Windows Form Designer.
            InitializeComponent()

            'Add any initialization after the InitializeComponent() call
            lblMessage.Text = MessageString
      End Sub

      'Form overrides dispose to clean up the component list.
      Protected Overloads Overrides Sub Dispose(ByVal disposing As Boolean)
            If disposing Then
                  If Not (components Is Nothing) Then
                        components.Dispose()
                  End If
            End If
            MyBase.Dispose(disposing)
      End Sub

      'Required by the Windows Form Designer
      Private components As System.ComponentModel.IContainer

      'NOTE: The following procedure is required by the Windows Form Designer
      'It can be modified using the Windows Form Designer.  
      'Do not modify it using the code editor.
      Friend WithEvents lblMessage As System.Windows.Forms.Label
      Friend WithEvents btnYes As System.Windows.Forms.Button
      Friend WithEvents btnNo As System.Windows.Forms.Button
      <System.Diagnostics.DebuggerStepThrough()> Private Sub InitializeComponent()
            Me.lblMessage = New System.Windows.Forms.Label
            Me.btnYes = New System.Windows.Forms.Button
            Me.btnNo = New System.Windows.Forms.Button
            Me.SuspendLayout()
            '
            'lblMessage
            '
            Me.lblMessage.Anchor = CType((((System.Windows.Forms.AnchorStyles.Top Or System.Windows.Forms.AnchorStyles.Bottom) _
                              Or System.Windows.Forms.AnchorStyles.Left) _
                              Or System.Windows.Forms.AnchorStyles.Right), System.Windows.Forms.AnchorStyles)
            Me.lblMessage.Location = New System.Drawing.Point(32, 30)
            Me.lblMessage.Name = "lblMessage"
            Me.lblMessage.Size = New System.Drawing.Size(308, 38)
            Me.lblMessage.TabIndex = 0
            Me.lblMessage.Text = "Label1"
            '
            'btnYes
            '
            Me.btnYes.Location = New System.Drawing.Point(112, 84)
            Me.btnYes.Name = "btnYes"
            Me.btnYes.TabIndex = 1
            Me.btnYes.Text = "Button1"
            '
            'btnNo
            '
            Me.btnNo.Location = New System.Drawing.Point(194, 84)
            Me.btnNo.Name = "btnNo"
            Me.btnNo.TabIndex = 2
            Me.btnNo.Text = "Button2"
            '
            'CustomMsgBox
            '
            Me.AutoScaleBaseSize = New System.Drawing.Size(5, 13)
            Me.ClientSize = New System.Drawing.Size(364, 131)
            Me.Controls.Add(Me.btnNo)
            Me.Controls.Add(Me.btnYes)
            Me.Controls.Add(Me.lblMessage)
            Me.Name = "CustomMsgBox"
            Me.Text = "Form1"
            Me.ResumeLayout(False)

      End Sub

#End Region

      Private Sub btnYes_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnYes.Click
            Me.DialogResult = DialogResult.Yes
            Me.Hide()
      End Sub

      Private Sub btnNo_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnNo.Click
            Me.DialogResult = DialogResult.No
            Me.Hide()
      End Sub
End Class


Then you can call it by using something like this:

      Dim msg As New CustomMsgBox("This is the message.  Please press Yes or No.")
      Dim result As MsgBoxResult

      msg.btnYes.Text = "Yes"
      msg.btnNo.Text = "No"
      result = msg.ShowDialog()

      MsgBox("The result was: " & result.ToString)
0
 
Éric MoreauSenior .Net ConsultantCommented:
if you only want to translate the buttons, see http://www.codeproject.com/Purgatory/messageboxhook.asp

alson have a look at an article I wrote in January 2006 from http://emoreau.s2i.com/
0
 
Éric MoreauSenior .Net ConsultantCommented:
you should split points between ZeonFlash and me.
0

Featured Post

Hire Technology Freelancers with Gigs

Work with freelancers specializing in everything from database administration to programming, who have proven themselves as experts in their field. Hire the best, collaborate easily, pay securely, and get projects done right.

  • 2
  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now