S
Sara
Hello there,
Iam creating a user control with 2 buttons, And i have a public
static variable i'll be changing the value of the variable in the
button click events.
When i consume the user control in the winforms application how to
automatically get the value of the public variable on click of the user
control.
user control code
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Drawing;
using System.Data;
using System.Text;
using System.Windows.Forms;
namespace WindowsControlLibrary2
{
public partial class UserControl1 : UserControl
{
public static string msButtonClicked;
public UserControl1()
{
InitializeComponent();
}
public UserControl1(Delegate p)
{
InitializeComponent();
}
private void Button1_Click(object sender, EventArgs e)
{
msButtonClicked = "Val1";
}
private void Button2_Click(object sender, EventArgs e)
{
msButtonClicked = "Val2";
}
private void Button3_Click(object sender, EventArgs e)
{
msButtonClicked = "Val3";
}
private void Button4_Click(object sender, EventArgs e)
{
msButtonClicked = "Val4";
}
}
}
consuming page
i want value to be popped up in userControl11_click event
private void userControl11_Load(object sender, EventArgs e)
{
MessageBox.Show(WindowsControlLibrary2.UserControl1.msButtonClicked);
//EventHandler handler = new EventHandler(a);
//userControl11.Click += handler;
}
Regards
Saravanan K
Iam creating a user control with 2 buttons, And i have a public
static variable i'll be changing the value of the variable in the
button click events.
When i consume the user control in the winforms application how to
automatically get the value of the public variable on click of the user
control.
user control code
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Drawing;
using System.Data;
using System.Text;
using System.Windows.Forms;
namespace WindowsControlLibrary2
{
public partial class UserControl1 : UserControl
{
public static string msButtonClicked;
public UserControl1()
{
InitializeComponent();
}
public UserControl1(Delegate p)
{
InitializeComponent();
}
private void Button1_Click(object sender, EventArgs e)
{
msButtonClicked = "Val1";
}
private void Button2_Click(object sender, EventArgs e)
{
msButtonClicked = "Val2";
}
private void Button3_Click(object sender, EventArgs e)
{
msButtonClicked = "Val3";
}
private void Button4_Click(object sender, EventArgs e)
{
msButtonClicked = "Val4";
}
}
}
consuming page
i want value to be popped up in userControl11_click event
private void userControl11_Load(object sender, EventArgs e)
{
MessageBox.Show(WindowsControlLibrary2.UserControl1.msButtonClicked);
//EventHandler handler = new EventHandler(a);
//userControl11.Click += handler;
}
Regards
Saravanan K