Closed. This question needs debugging details. It is not currently accepting answers.
Edit the question to include desired behavior, a specific problem or error, and the shortest code necessary to reproduce the problem. This will help others answer the question.
Closed 3 years ago.
Improve this question
namespace stock4
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
this.SetStyle(ControlStyles.ResizeRedraw, true);
this.chart1.AxisViewChanged += chart1_AxisViewChanged;
this.chart1.MouseMove += new System.Windows.Forms.MouseEventHandler(this.chart1_MouseMove);
}
private void CandleStick_Load(object sender, EventArgs e)
{
CHART();
}
string path = #"C:\Users\1\Documents\Visual Studio 2013\Projects\stock3\stock3\bin\Debug\#S-PG1440.csv";
static int count = System.IO.File.ReadAllLines(#"C:\Users\1\Documents\Visual Studio 2013\Projects\stock3\stock3\bin\Debug\#S-PG1440.csv").Length;
int[] index = new int[count];
DateTime[] nums = new DateTime[count];
double[,] mass = new double[count, 4];
public void CHART()
{
//Here the data from the file is read and entered into the array.
//chart1.Series["price"].Points.AddXY(index[i], mass[i, 1], mass[i, 2], mass[i, 0], mass[i, 3]);
}
private void chart1_AxisViewChanged(object sender, ViewEventArgs e)
{
//Autoscaling the graph
}
public static string str;
private void button1_Click(object sender, EventArgs e)
{
Form newForm = new Form();
newForm.DoubleBuffered = true;//Error 1 Cannot access
//protected member 'System.Windows.Forms.Control.DoubleBuffered'
//via a qualifier of type 'System.Windows.Forms.Form';
//the qualifier must be of type 'stock4.Form1'
//(or derived from it)
newForm.Show();
newForm.Width = 150;
newForm.Height = 230;
newForm.BackColor = Color.White;
newForm.Paint += new PaintEventHandler(MyPaintHandler);
}
private void chart1_MouseMove(object sender, MouseEventArgs e)
{
chart1.ChartAreas[0].CursorX.SetCursorPixelPosition(e.Location, false);
chart1.ChartAreas[0].CursorY.SetCursorPixelPosition(e.Location, false);
int val = (int)chart1.ChartAreas[0].CursorX.Position;
if (val >= 0)
{
double current = chart1.ChartAreas[0].CursorY.Position;
str = "time: " + nums[val] + "\n" +
"current: " + current + "\n" +
"open: " + mass[val, 0] + "\n" +
"high: " + mass[val, 1] + "\n" +
"low: " + mass[val, 2] + "\n" +
"close: " + mass[val, 3];
}
}
static void MyPaintHandler(object objSender, PaintEventArgs pea)
{
Form newForm = (Form)objSender;
Graphics grfx = pea.Graphics;
grfx.DrawString(str, newForm.Font, Brushes.Black, 0, 0);
newForm.Invalidate();
Thread.Sleep(1);
}
}
}
I read the data from the form and pass it to another for display.
I create a form to display when a button event occurs(button1_Click).
Data for "str" is taken from another form.
Perhaps the second form is not needed?
I need a separate window from the main form to display the data.
UPDATED THE CODE! Part of the code is not on the subject was removed from the comments.
How do I place the string " newForm.DoubleBuffered = true " in "button1_Click" without errors? It is possible a code sample?
Forget about painting, doublebuffering etc.
Simply add a Label control to the 2nd form and access it in the chart's MouseMove event!
Make newForm a class level variable:
Form newForm = null;
In your button click write something like this:
newForm = new Form();
..
Label lbl = new Label() { Name = "myLabel", Parent = newForm };
newForm.Show();
In your MouseMove write something like this:
if (newForm != null && newForm.Controls.ContainsKey("myLabel"))
((Label)newForm.Controls["myLabel"]).Text = str;
Very simple, no flicker and you are free to style the Label in any way you like.
Related
I have questions in my program that are jumbled up words and the user tries to un-jumble them. I want them to do this by them clicking multiple picture which have certain letters on it to form the word but I don't know how to connect the picture I have to a certain letter (e.g. Say I have a picture of the letter "a" how do I connect it so that the program knows when that picture is pressed the letter a is pressed).
This is the coding I have so far (to randomize the question and link the answers to it).
*Also I'm very new to coding so any suggestions please can you show what exactly to add/change to my code.
public partial class Level1 : Form
{
Random rnd = new Random(); //sets the random variable
List<string> strStrings = new List<string>() { "ZUZB", "HXAO", "MXAE", "KYCU", "CWEH", "PHIC", "HOCP", "SXIA", "ISHF", "KOJE" };//displays wprds om a list
Dictionary<string, string> dictStrings = new Dictionary<string, string>() //dictionary containing the word as the key, and the answer as the value in the key/value pair.
{
{ "ZUZB", "BUZZ" },
{ "HXAO", "HOAX" },
{ "MXAE", "EXAM" },
{ "KYCU", "YUCK" },
{ "CWEH", "CHEW" },
{ "PHIC", "CHIP" },
{ "HOCP", "CHOP" },
{ "SXIA", "AXIS" },
{ "ISHF", "FISH" },
{"KOJE", "JOKE" }
};
public Level1()
{
InitializeComponent();
}
int skip; //declares the skip variable
int score; //declares the score variable
int question; //decalres the question variable
private void nextButton_Click(object sender, EventArgs e)
{
if (strStrings.Count > 0)
{
string rndWord = strStrings[rnd.Next(0, strStrings.Count())];
lbljumble.Text = rndWord;
strStrings.Remove(rndWord);
}
else
{
lbljumble.Text = "No more questions!";
}
answerLabel.Text = ""; //randomly displays questions in the label until there are no more questions left to ask
score += 10; //add 10 to score and display in label
lblscore.Text = Convert.ToString(score);
question += 1; //add one to question number and display in label
lblqnum.Text = Convert.ToString(question);
tmrtime.Interval = (tmrtime.Interval) - 100; //amount of time taken after each question
}
private void answerButton_Click(object sender, EventArgs e)
{
string answer = (dictStrings.TryGetValue(lbljumble.Text, out answer)) ? answer : "";
answerLabel.Text = answer; //displays answer in label after the answer button is pressed to display the corresponding answer to the question
}
private void btnskip_Click(object sender, EventArgs e)
{
skip = 1; //skip equals 1
if (skip == 1) //of skip equals one
{
skip--; //take one from skip
lblskip.Text = " remaining: no"; //display that no skips are available
}
else
{
lblskip.Text = "No skips remaining"; //display no skips remaining
}
}
}
}
If I understand your question correctly you would like to know what letter was selected/clicked by the user.
You can dynamically create picture boxes, assign the .Name of the picture box to the value you would like the picture box to have then subscribe to the Click event for each picture box.
In the click event check the name of the sending picture box object sender. (you could alternatively use the pictureBx.Tag if you don't want to use the pictureBx.Name )
Here is an example form.
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
lblAnswer.Text = "";
DrawLeters();
}
string checkAnswer = "check";
void DrawLeters()
{
this.SuspendLayout();
string[] alphabet = "a,b,c,d,e,f,g,h,i,j,k,l,m,n,o,p,q,r,s,t,u,v,w,x,y,z".Split(",");
var pictureLocation = new Point(0, 0);
for (int i = 0; i < alphabet.Length; i++)
{
//Create a picture box
PictureBox pictureBx = new PictureBox();
//set the default location of the box (0,0) in this scenario
pictureBx.Location = pictureLocation;
//make the box 16 by 16
pictureBx.Size = new Size(16, 16);
//set the name of the box to that of the letter it represents
pictureBx.Name = alphabet[i];
//assign a click event to the box
pictureBx.Click += PictureBx_Click;
//now create the image that will fill the box
Image img = new Bitmap(16, 16);
using (Graphics graph = Graphics.FromImage(img))
{
graph.Clear(Color.White);
Brush textBrush = new SolidBrush(Color.Black);
graph.DrawString(pictureBx.Name, this.Font, textBrush, 0, 0);
graph.Save();
}
//assign the image to the box
pictureBx.Image = img;
//add the box to the form
this.Controls.Add(pictureBx);
//change the location for the next box
pictureLocation.X += 17;
if (i % 10 == 0 && i > 0)
{
pictureLocation.Y += 17;
pictureLocation.X = 0;
}
}
this.ResumeLayout(false);
this.PerformLayout();
}
private void PictureBx_Click(object sender, EventArgs e)
{ // assign the clicked value to the answer label
if (sender is PictureBox pbx)
lblAnswer.Text += pbx.Name;
}
private void checkAnswerBtn_Click(object sender, EventArgs e)
{
//check the answer
if (lblAnswer.Text == checkAnswer)
lblFeedback.Text = "Correct!!";
else
lblFeedback.Text = "NO!!";
}
private void clearBtn_Click(object sender, EventArgs e)
{
//clear the answer label
lblAnswer.Text = "";
}
}
and the result is this.
i'm just checking that the answer is check you would use your own logic to determine the correct answer.
You can add some picture-boxes and name them as Letter_a_pb, Letter_b_pb etc., create a Click event, and then create an if statement to check which pictureBox is clicked and if it equal to the letter 'a'.
For instance:
string question = "a";
private void Letter_a_pb_Click(object sender, EventArgs e)
{
if (question == "a")
MessageBox.Show("Excellent!");
else
MessageBox.Show("Try Again!");
}
Let me know if this is what you've searched for.
I have a teechart which has multiple series and I want use the markstip to show out both label value and the series name when mouse over. How could I do that?
Chart.Tooltip1 = new Steema.TeeChart.Tools.MarksTip(Chart);
Chart.Tooltip1.Style = MarksStyles.Labelvalue;
Chart.Tooltip1.GetText += new Steema.TeeChart.(tooltip1_GetText);
You can use series' GetSeriesMark event for that, for example:
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
InitializeChart();
}
private void InitializeChart()
{
tChart1.Series.Add(new Steema.TeeChart.Styles.Bar()).FillSampleValues();
tChart1[0].GetSeriesMark += Form1_GetSeriesMark;
tChart1[0].Marks.Visible = false;
tChart1.Tools.Add(new Steema.TeeChart.Tools.MarksTip());
}
void Form1_GetSeriesMark(Steema.TeeChart.Styles.Series series, Steema.TeeChart.Styles.GetSeriesMarkEventArgs e)
{
e.MarkText = "X: " + series.XValues[e.ValueIndex].ToString() + ", Y: " + series.YValues[e.ValueIndex].ToString() + " - " + series.ToString();
}
}
I have 2 different Forms. My first form Form1 is the main form that has a TextBox called textbox1. My other form is called FontSettings and is supposed to be used so Form1 can inherit FontSettings data. I am trying to send a string and 2 integers from FontSettings to Form1. It looks like this.
FontSettings:
Form1 form1 = new Form1();
form1.insertFont(family, size, color);
Form1:
public void insertFont(string a, int b, string c)
{
if (textBox1.SelectionLength > 0)
{
xx = textBox1.SelectedText;
textBox1.SelectedText = textBox1.SelectedText.Replace(xx, "" + a + "\" + b + c + "a");
}
else
{
textBox1.Paste("" + a + "\" + b + c + "a");
}
}
The string and both integers used, are public.
Someone please describe to me what I am doing wrong?
Simples. See the below code which opens FontSettings form from 'form1'
FontSettings newform = new FontSettings();
newform.ShowDialog();
MessageBox.Show(newform.MyString);
MessageBox.Show(string.Format("{0}", newform.MyInt1));
MessageBox.Show(string.Format("{0}", newform.MyInt2));
Then in the FontSettings form, create some public properties so they can be referenced from 'form1'
public string MyString { get; set; }
public int MyInt1 { get; set; }
public int MyInt2 { get; set; }
Then in a button click do the following:
private void button1_Click(object sender, EventArgs e)
{
MyString = "some value here...";
MyInt1 = 28;
MyInt2 = 77;
this.Close();
}
You want to modify form1 property from forsettings, one way to do it is find the form1 contrls and modify it directly as below
private void button1_Click(object sender, EventArgs e)
{
TextBox t = Application.OpenForms["Form1"].Controls["textBox1"] as TextBox;
t.Text = "some value here...";
// do the same for the other two controls
this.Close();
}
From your description,it sounds like you are making a text editor kind of application like Notepad.Well, if this is the case then its a lot easier to use three static fields.The code below will make this clear.
To proceed define three static fields in Form1 class,like this;
public static string family="";
public static int size=0;
public static string color="";
I guess you have three TextBoxes' and a Close Button on class FontSettings,if this is so,then add the code below to Click Event of Button;
if (!String.IsNullOrEmpty(textBoxFamily.Text))//Check if textBoxFamily is not empty.
{
Form1.family = textBoxFamily.Text;
if (!String.IsNullOrEmpty(textBoxSize.Text))//Check if textBoxSize is not empty.
{
Form1.size = Convert.ToInt32(textBoxSize.Text);
if (!String.IsNullOrEmpty(textBoxColor.Text))//Check if textBoxColor is not empty.
{
Form1.color = textBoxColor.Text;
this.Close();//If everything happens correctly,close FontSettings.
}
}
}
Now as we have declared the fields in Form1,we can use their values directly,like this;
public void insertFont()
{
if (textBox1.SelectionLength > 0)
{
xx = textBox1.SelectedText;
textBox1.SelectedText = textBox1.SelectedText.Replace(xx, "" + family + "\" + size + color + "a");
}
else
{
textBox1.Paste("" + family + "\" + size + color + "a");
}
}
Hope it's enough to get you back on track.If there's anything left,please inform me.
I am working with windows form application in c#. I have installed licensed version of TeeChart for.net v3. I am trying to remove some unwanted portion of TeeChart.
Thanks to stackoverflow website users, they helped me to create a mouse click popup on TeeChart. Now i want to implement some functionality for that popup clicks.
using the below code i am able to create mouse right click popup.
double m_dblTempVolFromTo = 0;
double dtFromTo = 0;
private void mainTChart_MouseUp(object sender, MouseEventArgs e)
{
if (!checkBoxIsTime.Checked && e.Button == MouseButtons.Right)
{
m_dblTempVolFromTo = mainTChart.Series[0].XScreenToValue(e.X);
mainTChart.ContextMenu = new ContextMenu();
mainTChart.ContextMenu.MenuItems.Add(new MenuItem("From " + m_dblTempVolFromTo + " cc"));
mainTChart.ContextMenu.MenuItems.Add(new MenuItem("To " + m_dblTempVolFromTo + " cc"));
mainTChart.ContextMenu.MenuItems[0].Click += new EventHandler(From_Click);
mainTChart.ContextMenu.MenuItems[1].Click += new EventHandler(To_Click);
}
else if (checkBoxIsTime.Checked && e.Button == MouseButtons.Right)
{
DateTime dt;
dtFromTo = mainTChart.Series[0].XScreenToValue(e.X);
DateTime.TryParse(dtFromTo.ToString(), out dt);
mainTChart.ContextMenu = new ContextMenu();
mainTChart.ContextMenu.MenuItems.Add(new MenuItem("From " + dt.TimeOfDay.ToString() ));
mainTChart.ContextMenu.MenuItems.Add(new MenuItem("To " + dt.TimeOfDay.ToString()));
mainTChart.ContextMenu.MenuItems[0].Click += new EventHandler(From_Click);
mainTChart.ContextMenu.MenuItems[1].Click += new EventHandler(To_Click);
}
}
The above code is creating popup like as shown below.
I am trying to implement functionality for "For 7.6 cc" and "To 7.6 cc".
when i click "To 7.6 cc" then the chart should remove from "0 to 7.6" scale and remaining part should be there. As well the same apply for "From 145 cc" click, it has to remove the chart from "145 to 150(end of scale)".
click on "To" is using to remove starting portion of chart and click on "From" is using to remove end portion of chart.
I have tried like this but i am not able to get what i want.
void From_Click(object sender, EventArgs e)
{
if (!checkBoxIsTime.Checked)
{
var destBitmap = mainTChart.Export.Image.Bitmap.Clone(new Rect(0, 0, 100, 200), sourceBitmap.PixelFormat);
}
}
void To_Click(object sender, EventArgs e)
{
}
even i have tried with this code also
void mainTChart_GetLegendRect(object sender, mainTChart.GetLegendRectEventArgs e)
{
Rectangle cropRect = e.Rectangle;
Bitmap legendImg = new Bitmap(cropRect.Width, cropRect.Height);
using (Graphics g = Graphics.FromImage(legendImg))
{
g.DrawImage(chartBmp, new Rectangle(0, 0, mainTChart.Width, mainTChart.Height),
cropRect,
GraphicsUnit.Pixel);
}
}
nothing is working for me. Can any one help me with this task.
Thanks in advance.
Edited
when i have X-axis as time then i am not able to get display time on mouse click. The code I have tried as shown below
DateTime dt;
dtFromTo = mainTChart.Series[0].XScreenToValue(e.X);
DateTime.TryParse(dtFromTo.ToString(), out dt);
mainTChart.ContextMenu = new ContextMenu();
mainTChart.ContextMenu.MenuItems.Add(new MenuItem("From " + dt.TimeOfDay.ToString() ));
mainTChart.ContextMenu.MenuItems.Add(new MenuItem("To " + dt.TimeOfDay.ToString()));
I am getting like this
I am getting as shown in the above image but want to display the equivalent time on mouse right click. I am getting some value to this variable "dtFromTo" like 41322.9876587965" but i am not able to convert that value into time. please help me.
Known the values you want to "cut" From/To, you can just set the Bottom axis Minimum and Maximum properties.
when i click "To 7.6 cc" then the chart should remove from "0 to 7.6"
scale and remaining part should be there
This would be:
mainTChart.Axes.Bottom.AutomaticMinimum = false;
mainTChart.Axes.Bottom.Minimum = 7.6;
As well the same apply for "From 145 cc" click, it has to remove the
chart from "145 to 150(end of scale)".
This would be done setting the Maximum:
mainTChart.Axes.Bottom.AutomaticMaximum = false;
mainTChart.Axes.Bottom.Maximum = 145;
So I think this should to the trick:
void From_Click(object sender, EventArgs e)
{
mainTChart.Axes.Bottom.AutomaticMaximum = false;
mainTChart.Axes.Bottom.Maximum = m_dblTempVolFromTo;
}
void To_Click(object sender, EventArgs e)
{
mainTChart.Axes.Bottom.AutomaticMinimum = false;
mainTChart.Axes.Bottom.Minimum = m_dblTempVolFromTo;
}
I'd also suggest you to create the ContextMenu in mainTChart_MouseDown event insted of mainTChart_MouseUp because creating it at the mainTChart_MouseUp event is too late, the ContextMenu shown won't show the updated version.
Edit:
For DateTime XValues, the wrong line is this one:
DateTime.TryParse(dtFromTo.ToString(), out dt);
Here it is the full code that seems to work fine for me here:
private void InitializeChart()
{
mainTChart.Aspect.View3D = false;
Line line1 = new Line(mainTChart.Chart);
line1.XValues.DateTime = true;
line1.FillSampleValues();
mainTChart.Axes.Bottom.Labels.DateTimeFormat = "hh:mm";
mainTChart.MouseDown += new MouseEventHandler(mainTChart_MouseDown);
}
double m_dblTempVolFromTo = 0;
double dtFromTo = 0;
void mainTChart_MouseDown(object sender, MouseEventArgs e)
{
if (!mainTChart.Axes.Bottom.IsDateTime && e.Button == MouseButtons.Right)
{
m_dblTempVolFromTo = mainTChart[0].XScreenToValue(e.X);
mainTChart.ContextMenu = new ContextMenu();
mainTChart.ContextMenu.MenuItems.Add(new MenuItem("From " + m_dblTempVolFromTo + " cc"));
mainTChart.ContextMenu.MenuItems.Add(new MenuItem("To " + m_dblTempVolFromTo + " cc"));
mainTChart.ContextMenu.MenuItems[0].Click += new EventHandler(From_Click);
mainTChart.ContextMenu.MenuItems[1].Click += new EventHandler(To_Click);
}
else if (e.Button == MouseButtons.Right)
{
dtFromTo = mainTChart[0].XScreenToValue(e.X);
String stFromTo = mainTChart.Axes.Bottom.Labels.LabelValue(dtFromTo);
mainTChart.ContextMenu = new ContextMenu();
mainTChart.ContextMenu.MenuItems.Add(new MenuItem("From " + stFromTo));
mainTChart.ContextMenu.MenuItems.Add(new MenuItem("To " + stFromTo));
mainTChart.ContextMenu.MenuItems[0].Click += new EventHandler(From_Click);
mainTChart.ContextMenu.MenuItems[1].Click += new EventHandler(To_Click);
}
}
void From_Click(object sender, EventArgs e)
{
mainTChart.Axes.Bottom.AutomaticMaximum = false;
if (!mainTChart.Axes.Bottom.IsDateTime)
mainTChart.Axes.Bottom.Maximum = m_dblTempVolFromTo;
else
mainTChart.Axes.Bottom.Maximum = dtFromTo;
}
void To_Click(object sender, EventArgs e)
{
mainTChart.Axes.Bottom.AutomaticMinimum = false;
if (!mainTChart.Axes.Bottom.IsDateTime)
mainTChart.Axes.Bottom.Minimum = m_dblTempVolFromTo;
else
mainTChart.Axes.Bottom.Minimum = dtFromTo;
}
I'm trying to make a simple program with GUI in c# but unfortunately I have some difficulties. Now I'll try to explain the basic structure of my program. I have 3 classes for three different groups of people(University Professors, University Students and people who don't work or study either). I have some methods for reading information from a file(professor's title, name, university name, student's faculty number, etc.). I read the file line by line and save the information in an object of type one of the 3 classes. After that I put that object in a List. So here comes my problem. I want to read every object from the list and take its name and put in on a dynamically created labels on other windows form. Here it is a little part of my code:
private void button1_Click(object sender, EventArgs e)
{
ForeignPeople fPeople = new ForeignPeople();
UniversityProfessors uProf = new UniversityProfessors();
UniversityStudents uStudents = new UniversityStudents();
if (radioButton1.Checked == true)
{
objList1 = loadList();
Form2 f2 = new Form2();
for (int i = 0; i < objList1.Count; i++)
{
if (objList1[i] is UniversityStudents)
{
uStudents = (UniversityStudents)objList1[i];
tableLayoutPanel1.GrowStyle = TableLayoutPanelGrowStyle.AddRows;
Label et_tag = new Label();
et_tag.Name = "label" + i.ToString();
et_tag.Text = uStudents.getFirstName().ToString() + " " + uStudents.getLastName().ToString();
et_tag.AutoSize = true;
f2.tableLayoutPanel1.Controls.Add(et_tag, 0, i);
Label op = new Label();
op.AutoSize = true;
op.Text = "description";
f2.tableLayoutPanel1.Controls.Add(op, 1, i);
}
else if (objList1[i] is UniversityProfessors)
{
uProf = (UniversityProfessors)objList1[i];
tableLayoutPanel1.GrowStyle = TableLayoutPanelGrowStyle.AddRows;
Label et_tag = new Label();
Label label = new Label();
et_tag.Name = "label" + i.ToString();
et_tag.Text = uProf.getFirstName().ToString() + " " + uProf.getLastName().ToString();
et_tag.AutoSize = true;
f2.tableLayoutPanel1.Controls.Add(et_tag, 0, i);
Label op = new Label();
op.AutoSize = true;
op.Text = "description";
f2.tableLayoutPanel1.Controls.Add(op, 1, i);
}
else if (objList1[i] is ForeignPeople)
{
fPeople = (ForeignPeople)objList1[i];
String name, Name;
tableLayoutPanel1.GrowStyle = TableLayoutPanelGrowStyle.AddRows;
Label et_tag = new Label();
et_tag.Name = "label" + i.ToString();
et_tag.Text = fPeople.getFirstName().ToString() + " " + fPeople.getLastName().ToString();;
et_tag.AutoSize = true;
f2.tableLayoutPanel1.Controls.Add(et_tag, 0, i);
Label op = new Label();
op.AutoSize = true;
op.Text = "description";
f2.tableLayoutPanel1.Controls.Add(op, 1, i);
}
}
f2.FormClosed += new FormClosedEventHandler(childFormClosed);
f2.Show();
this.Hide();
}
But if I have two or more lines which belongs to one Object(for example I have two or more students, or two or more professors in the file) the text of all the labels becomes with the name of the last read object. I know that the problem is in the List or in the cast which I make but I can't figure out another way of doing what I want. I'll be extremely grateful if someone can help.
In addition to the change that phoog mentioned in the comments, I would also move the instantiation of your "people" objects down into the section for each within the loop. That way you can be sure that the old one is being properly destroyed. I would also add a check to make sure that the cast worked.
private void button1_Click(object sender, EventArgs e)
{
if (radioButton1.Checked == true)
{
objList1 = loadList();
Form2 f2 = new Form2();
for (int i = 0; i < objList1.Count; i++)
{
if (objList1[i] is UniversityStudents)
{
UniversityStudents uStudents = (UniversityStudents)objList1[i];
if (uStudents != null)
{
// do stuff
}
else
{
// do something sensible with the error here
}
}
// if clauses for the other "people" objects
// ...
}
f2.FormClosed += new FormClosedEventHandler(childFormClosed);
f2.Show();
this.Hide();
}
}