0% found this document useful (0 votes)
34 views2 pages

Using Using Using Using Using Using Using Using Namespace Public Partial Class Public

The document contains code for a Windows Forms application with 5 radio buttons that populate a list box with different sequences based on the radio button checked. Radio button 1 populates the list box with numbers from 1 to the value in text box 1. Radio button 2 populates in descending order. Radio button 3 populates with even numbers. Radio button 4 populates with odd numbers. Radio button 5 populates with double the numbers. The text changed event handler clears selections.

Uploaded by

Miloš Marković
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
34 views2 pages

Using Using Using Using Using Using Using Using Namespace Public Partial Class Public

The document contains code for a Windows Forms application with 5 radio buttons that populate a list box with different sequences based on the radio button checked. Radio button 1 populates the list box with numbers from 1 to the value in text box 1. Radio button 2 populates in descending order. Radio button 3 populates with even numbers. Radio button 4 populates with odd numbers. Radio button 5 populates with double the numbers. The text changed event handler clears selections.

Uploaded by

Miloš Marković
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 2

using System;

using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;

namespace WindowsFormsApplication1
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}

private void radioButton1_CheckedChanged(object sender, EventArgs e)


{
if (radioButton1.Checked)
{
int N = Convert.ToInt32(textBox1.Text);
listBox1.Items.Clear();
for (int i = 1; i <= N; i++)
listBox1.Items.Add(i);
}
}

private void radioButton2_CheckedChanged(object sender, EventArgs e)


{
if (radioButton2.Checked)
{
int N = Convert.ToInt32(textBox1.Text);
listBox1.Items.Clear();
while (N > 0)
{
listBox1.Items.Add(N);
N--;
}
}
}

private void radioButton3_CheckedChanged(object sender, EventArgs e)


{
if (radioButton3.Checked)
{
int N = Convert.ToInt32(textBox1.Text);
listBox1.Items.Clear();
for (int i=1; i<= N; i++)
listBox1.Items.Add((2*i)/2);
}

}
private void radioButton4_CheckedChanged(object sender, EventArgs e)
{
if (radioButton4.Checked)
{
int N = Convert.ToInt32(textBox1.Text);
listBox1.Items.Clear();
for (int i = 1; i <= N; i++)
listBox1.Items.Add(2 * i - 1);
}
}

private void radioButton5_CheckedChanged(object sender, EventArgs e)


{
if (radioButton5.Checked)
{
int N = Convert.ToInt32(textBox1.Text);
listBox1.Items.Clear();
for (int i = 1; i <= N; i++)
listBox1.Items.Add(2 * i);
}
}

private void textBox1_TextChanged(object sender, EventArgs e)


{
radioButton1.Checked = false;
radioButton2.Checked = false;
radioButton3.Checked = false;
radioButton4.Checked = false;
radioButton5.Checked = false;
listBox1.Items.Clear();
}

}
}

You might also like