Wednesday, 20 October 2010

examples with source code to desingn an application with checkbox and adiobutton

//examples with source code to desingn an application with checkbox and adiobutton

public partial class Form6 : Form{
int count = 0;
public Form6()
{
InitializeComponent();
}
private void checkBox1_CheckedChanged(object sender, EventArgs e)
{
CheckBox cb = sender as CheckBox;
int amt = int.Parse(txtAmount.Text);
if (cb.Checked)
{
count += 1;
amt += Convert.ToInt32(cb.Tag);
}
else
{
count -= 1;
amt -= Convert.ToInt32(cb.Tag);
}
txtAmount.Text = amt.ToString();
if (count == 0)
radioButton1.Checked = true;
}
private void radioButton1_CheckedChanged(object sender, EventArgs e)
{
int amt = int.Parse(txtAmount.Text);
if (amt > 0)
{
RadioButton rb = sender as RadioButton;
if (rb.Checked)
amt += Convert.ToInt32(rb.Tag);
else
amt -= Convert.ToInt32(rb.Tag);
txtAmount.Text = amt.ToString();
}
else
radioButton1.Checked = true;
}

examples with source code of how to raise an event

//examples with source code of how to raise an event
public Form2()
{
InitializeComponent();
}
private void Form2_Load(object sender, EventArgs e)
{
MessageBox.Show("Event Raised");

examples with source-code to display where user has clicked

public Form1()
{
InitializeComponent();
}
private void Form1_Load(object sender, EventArgs e)
{
MessageBox.Show("Welcome to windows applications");
}
private void Form1_Click(object sender, EventArgs e)
{
MessageBox.Show("You have clicked on the form");
}
// example with source code to hidden literals
protected void Page_Load(object sender, EventArgs e)
{
if(!IsPostBack )
HiddenField1.Value = "0";


}
protected void Button2_Click(object sender, EventArgs e)
{

int count = Convert.ToInt32(HiddenField1.Value);
count++;

HiddenField1.Value = count.ToString();



Literal1.Text = "No. of clicks = " + HiddenField1.Value;
}