Tengo una clase que llama a un formulario. Y necesito que me regrese un
valor(si presiono el boton YES o el NO) a la clase como puedo hacerlo,
usualmente programo en VB, pero quiero empezar a cambiar mis programas a C#.
de antemano gracias por la ayuda.
Codigo de la clase
using System;
using System.Collections.Generic;
using System.Text;
using System.Drawing;
namespace clsMsgbox
{
public class Show
{
private int _wmsgresp;
public int wmsgrespx {
get { return _wmsgresp; }
set { _wmsgresp = value; }
}
public virtual int MessageBoxOk(string wlblmsg )
{
Frmmsgbox lfrmmsg =new Frmmsgbox();
lfrmmsg.btnNo.Visible = false;
lfrmmsg.btnYes.Text = "Ok";
lfrmmsg.btnYes.Location = new System.Drawing.Point(90, 267);
lfrmmsg.lblMsg.Text = wlblmsg;
lfrmmsg.ShowDialog();
lfrmmsg.Dispose();
lfrmmsg = null;
return 7;
}
public virtual int MessageBoxYesNo(string wlblmsg)
{
Frmmsgbox lfrmmsg =new Frmmsgbox();
int wresp = 0;
lfrmmsg.lblMsg.Text = wlblmsg;
lfrmmsg.ShowDialog();
if (lfrmmsg.btnNo.Tag == "1")
{
wresp = 7;
}
else
{ wresp = 6; }
lfrmmsg.Dispose();
lfrmmsg = null;
return wresp;
}
public Show(int _valor) { _wmsgresp = _valor; }
}
}
Codigo del Fomulario
namespace clsMsgbox
{
public partial class Frmmsgbox : Form
{
public Frmmsgbox()
{
InitializeComponent();
}
private void btnYes_Click(object sender, EventArgs e)
{
btnYes.Tag = "1";
this.Close();
}
private void btnNo_Click(object sender, EventArgs e)
{
btnNo.Tag = "1";
this.Close;
}
}
}
Leer las respuestas