Solved

language msgbox

Posted on 2006-10-30
8
230 Views
Last Modified: 2010-04-23
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
Comment
Question by:TheSonics
  • 2
  • 2
8 Comments
 
LVL 17

Expert Comment

by:ZeonFlash
ID: 17837022
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
 

Author Comment

by:TheSonics
ID: 17837029
sounsd good i have to derivate a class or do my own form ?
0
 
LVL 17

Accepted Solution

by:
ZeonFlash earned 250 total points
ID: 17837219
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
 
LVL 69

Assisted Solution

by:Éric Moreau
Éric Moreau earned 250 total points
ID: 17838747
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
 
LVL 69

Expert Comment

by:Éric Moreau
ID: 18033213
you should split points between ZeonFlash and me.
0

Featured Post

What Security Threats Are You Missing?

Enhance your security with threat intelligence from the web. Get trending threat insights on hackers, exploits, and suspicious IP addresses delivered to your inbox with our free Cyber Daily.

Join & Write a Comment

I think the Typed DataTable and Typed DataSet are very good options when working with data, but I don't like auto-generated code. First, I create an Abstract Class for my DataTables Common Code.  This class Inherits from DataTable. Also, it can …
It was really hard time for me to get the understanding of Delegates in C#. I went through many websites and articles but I found them very clumsy. After going through those sites, I noted down the points in a easy way so here I am sharing that unde…
This video gives you a great overview about bandwidth monitoring with SNMP and WMI with our network monitoring solution PRTG Network Monitor (https://www.paessler.com/prtg). If you're looking for how to monitor bandwidth using netflow or packet s…
This video explains how to create simple products associated to Magento configurable product and offers fast way of their generation with Store Manager for Magento tool.

747 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

13 Experts available now in Live!

Get 1:1 Help Now