Mitja Bonca 557 Nearly a Posting Maven

A class is a reference type. When an object of the class is created, the variable to which the object is assigned holds only a reference to that memory. When the object reference is assigned to a new variable, the new variable refers to the original object. Changes made through one variable are reflected in the other variable because they both refer to the same data.

A struct is a value type. When a struct is created, the variable to which the struct is assigned holds the struct's actual data. When the struct is assigned to a new variable, it is copied. The new variable and the original variable therefore contain two separate copies of the same data. Changes made to one copy do not affect the other copy.

In general, classes are used to model more complex behavior, or data that is intended to be modified after a class object is created. Structs are best suited for small data structures that contain primarily data that is not intended to be modified after the struct is created.

Mitja Bonca 557 Nearly a Posting Maven

Try and let me know, but remember, when working wit dgv control, best "tool" for populating it, is a dataTable. A good example you have here.

vedro-compota commented: ++++++ +1
Mitja Bonca 557 Nearly a Posting Maven

Which array exactly? Or string[], ArrayList, generic List ?
And how many columns has your dgv?

Just for your info, for populating dgv, its best practice to use DataSet (or DataTable). Its specially designed for that, becuase you can create columns and rows, its actually a copy of dgv. In arrays you CANNOT have any columns, so populating its hard - or better said - useless.

vedro-compota commented: +++++++++ +1
Mitja Bonca 557 Nearly a Posting Maven

Please take both examples, in the upper post and this one in here.
The same example would be with using keyword "out":

static void Main(string[] args)
        {
            int value = 2;
            List<string> list;
            CreateList(out list, value);

            for (int i = 0; i < list.Count; i++)
                Console.WriteLine("{0}", list[i]);
            Console.ReadLine();
        }

        private static void CreateList(out List<string> list, int howMany) 
        {
            list = new List<string>();
            for (int i = 0; i < howMany; i++)
            {
                string sItem;
                Calculate(out sItem, i);
                list.Add(sItem);
            }
        }

        private static void Calculate(out string item, int i)
        {
            switch (i)
            {
                case 0:
                    {
                        item = "one";
                        break;
                    }
                case 1:
                    {
                        item = "two";
                        break;
                    }
                case 2:
                    {
                        item = "three";
                        break;
                    }
                default:
                    {
                        item = "none";
                        break;
                    }
            }
        }
NewOrder commented: Thank you +0
Mitja Bonca 557 Nearly a Posting Maven

The loops have so much work, that the form is not responding. Thats is whole the code is going on in one thread. There are two solutions, or to use BackGroundWorker, or you put the loops into another thread, so the main thread of the form will be free of that code, and so it will be responsive.
The last option (of creating new thread) is easy and faster for beginners.

Mitja Bonca 557 Nearly a Posting Maven

How will you choose 3,5 or 7 option? You have to do an option to let the user chooses it, and then its simple - get the number user has choosen, and pass it to the method which will create the field of buttons to play:

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 Jan08Exercise
{
    public partial class Form1 : Form
    {
        public Form1()
        {
            InitializeComponent();
            this.comboBox1.Items.AddRange(new string[] { "3x3", "5x5", "7x7" });
        }

        private void button1_Click(object sender, EventArgs e)
        {
            string item = comboBox1.GetItemText(comboBox1.SelectedItem);
            if (item != String.Empty)
            {
                string sNumber = item.Substring(0, item.Length - 2);
                int value = Convert.ToInt32(sNumber);
                CreatingField(value);
            }
        }

        private void CreatingField(int value)
        {
            for (int x = 0; x < value; x++)//loop relating to rows
            {
                for (int y = 0; y < value; y++)//loop relating to columns
                {
                    nandcButton[x, y] = new Button();//Create the Buttons
                    nandcButton[x, y].Name = "nandcButton" + x + "," + y;//name and coordinates and set up number, number to show
                    nandcButton[x, y].Width = 60;
                    nandcButton[x, y].Height = 60;
                    nandcButton[x, y].Left = nandcButton[x, y].Left + nandcButton[x, y].Width + (x * 60);
                    nandcButton[x, y].Top = nandcButton[x, y].Top + nandcButton[x, y].Top + 50 + (y * 60); //Centre the button 
                    nandcButton[x, y].Click += new EventHandler(Button_Click); //links the above button spec.
                    //Add them to the container
                    nandcHolder.Controls.Add(nandcButton[x, y]);
                    nandcButton[x, y].Text = " "; //declares text
                }
            }
        }
    }
}

Hope it helps a bit.
If this is not something you wanted, …
Mitja Bonca 557 Nearly a Posting Maven

Maybe this will do? :

string filename = "f:\\date.txt";
            using (StreamReader stream = new StreamReader(filename))
            { 
                string line;
                while ((line = stream.ReadLine()) != null)
                {
                    string[] array = line.Split(' ');
                    int a = Convert.ToInt32(array[0]); //1.
                    string b = array[1];               //2.
                    string c = array[2];               //3.
                }
            }
Mitja Bonca 557 Nearly a Posting Maven

I dont find anything that can be connected with if,else loops in your code, ok it could be, but it would be too complicated.
In my opinion fawi`s approach is the right one, I will only modify it a bit, to suit your needs:

bool flag = false;
            for (int i = 0; i <= 2; i++)
            {
                for (int j = 0; j <= 2; j++)
                {
                    if (nandcButton[i, j] == "0")
                        flag = true;
                }
            }
            if (flag == true)
            {
                //the requirment has been fulfiled!
            }

Hope this helps,
Mitja

johnt68 commented: Thanks for the help +1
Mitja Bonca 557 Nearly a Posting Maven

This is some other solution:

void ReversingMethod()
        {
            string str = "This is a string that needs to be reversed";
            Array array = str.Split(' ');
            Array.Reverse(array);
            str = null;
            for (int i = 0; i < array.Length; i++)
            {
                str += array.GetValue(i) + " ";
            }
            MessageBox.Show("This is a reversed string:\n" + str);
        }
Mitja Bonca 557 Nearly a Posting Maven

This is what I meant:

// read CSV file
        private DataTable BuildDataTable(string fileFullPath, char seperator)
        {
            StreamReader myReader; //put a new instance of StreamReader here, so it will be accessable in whole method
            const int EOF = -1;

            DataTable myTable = new DataTable("MyTable");
            DataRow myRow;
            try
            {
                myReader = new StreamReader(fileFullPath);
            }
            catch (Exception ex)
            {
                MessageBox.Show("Error opening streamreader: " + ex.Message);
                return new DataTable("Empty");
            }
            try
            // Open file and read first line to determine how many fields there are.
            {
                string[] fieldValues = myReader.ReadLine().Split(new Char[] { seperator, ';' });
                // Adding the first line of data to data table (columnnames?
                // Create data columns accordingly
                for (int i = 0; i < fieldValues.Length; i++)
                {
                    myTable.Columns.Add(new DataColumn(fieldValues[i].ToString().Trim()));
                }
                //Now reading the rest of the data to data table
                while (myReader.Peek() != EOF)
                {
                    fieldValues = myReader.ReadLine().Split(new Char[] { seperator });
                    myRow = myTable.NewRow();
                    for (int i = 0; i < fieldValues.Length; i++)
                    {
                        myRow[i] = fieldValues[i].ToString().Trim();
                    }
                    myTable.Rows.Add(myRow);
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show("Error building datatable: " + ex.Message);
                return new DataTable("Empty");
            }
            finally
            {
                if (myReader != null)
                {
                    myReader.Close();
                }
            }
            myTable.AcceptChanges();
            return myTable;
        }

If this is not it, please let me know.
What bothers me, are those 2 chatch bloces. Do you have any issues with them? If not, its ok.

ddanbe commented: For the effort! +8
Mitja Bonca 557 Nearly a Posting Maven

I have chnaged a code a bit, and now it works:

private void ReadingFile()
        {
            using (StreamReader sr = new StreamReader(@"C:\1\map.txt"))
            {
                string line;
                // Read and display lines from the file until the end of 
                // the file is reached.
                while ((line = sr.ReadLine()) != null)
                {
                    if (line != String.Empty)
                        label1.Text = line + Environment.NewLine;
                }
            }
        }

I hope it does work for you too.
Mitja

Mitja Bonca 557 Nearly a Posting Maven

Where it hangs up? Or is it tryig to go into infinity in the while loop? If so, that means its still reading the file - mayne you read a file byte by byte (like I showed you on the previous example) and this is taking very long time - depends of the file lenght.
Otherwise I cannot see any other reason to hang up.
Take a look in a debug mode (put the break point and go line by line with pressing F11).

Hope it helps,
Mitja

Mitja Bonca 557 Nearly a Posting Maven

hmm... Did you save the data into a file in the same order then you are retreiving them back out?

the point is that you cannot just simply asign some binary data to something. You have to get the data into the text in some order, and then retreive them back in the same way:EXAMPLE!

If this is not enough its better to take a look into some other example, that you will learn how to use bytes and converted them back to the characters (strings, integers,...).

Give it some time and go through all the code slowely:
http://msdn.microsoft.com/es-es/library/system.io.binaryreader.aspx

Mitja Bonca 557 Nearly a Posting Maven

Why do you want to encode a text? A text its alredy encoded, dont you think. You only need to get it from the file into a label.

vedro-compota commented: +++++ +1
Mitja Bonca 557 Nearly a Posting Maven
Mitja Bonca 557 Nearly a Posting Maven
//get the selected item:
string value  = listBox1.SelectedItem.ToString();
//delete it:
listBox1.Items.Remove(value);

there is another way to get the selecte index (thats an integer) and then remove with using method "RemoveAt", like:

int index = listBox1.SelectedIndex;
listBox1.Items.RemoveAt(index);
ddanbe commented: You got a point here. +8
Mitja Bonca 557 Nearly a Posting Maven

You can test is in this way:
put on the from:
- textBox
- button
- label

Now create a method for a button_Click event and put use this code on it:

private void button1_Click(object sender, EventArgs e)
        {
            string sValue = textBox1.Text;
            int intValue = 0;
            decimal decValue = 0M;
            
            bool bValidating = int.TryParse(sValue, out intValue);
            if (!bValidating)
            {
                bValidating = decimal.TryParse(sValue, out decValue);
                if (!bValidating)
                    label1.Text = sValue + " is a string";
                else
                    label1.Text = sValue + " is a decimal";
            }
            else
                label1.Text = sValue + " is a integer";
        }

Hope it helps,
Mitja

Mitja Bonca 557 Nearly a Posting Maven

Change this row to:

this.dgvSubContractor[3, row].Value.ToString() = c.CheckingValue(e.Value.ToString()).ToString();

and btw, this is not a good way to check for the number. What happenes in case if the string you check in the "CheckingValue" method is not a number? In your case nothing, only the form of tel. number will not the ok (maybe tel. number will include letters).
And your checking method here is completely wortheless - why? Because in any case you return string. Even ifs its not a number.
You have to set the method to bool modifier and return true or false. If true, set the string to a tel. number format, if not, warn the user he entered wrong string.

Something like:

private void PopulatingDGV()
        {
            //... code

            if (e.ColumnIndex >= 0)
            {
                if (this.dgvSubContractor.Columns[e.ColumnIndex].Name == "TelNo")
                {
                    if (e.Value != null)
                    {
                        string value = e.Value.ToString();
                        bool bChecking = c.CheckingValue(value);
                        if (bChecking)
                            this.dgvSubContractor[3, row].Value.ToString() = String.Format("{0:(###) ###-####}", value);
                        else
                            MessageBox.Show("Wrong tel. number format. Please repair it...");
                    }
                }
                return;
            }
        }

        public static bool CheckingValue(string item)
        {
            long value = 0;
            bool bChecking = long.TryParse(item, out value);
            if (bChecking)
                return true;
            else
                return false;
        }

Hope this helps,
Mitja

ddanbe commented: Nice! +8
Mitja Bonca 557 Nearly a Posting Maven

Here is the code which shows you both:
(ps: button click even reverses the list, so you can see the difference in the code)

public Form1()
        {
            InitializeComponent();
            string[] array = new string[] { "D", "C", "A", "E", "B" };
            Array.Sort(array);
            listBox1.Items.AddRange(array);
        }

        private void buttonInvert_Click(object sender, EventArgs e)
        {
            int rows = listBox1.Items.Count;
            string[] array = new string[rows];
            for(int i=0;i<listBox1.Items.Count;i++)
            {
                array[i] = listBox1.Items[i].ToString();
            }
            Array.Reverse(array);
            listBox1.Items.Clear();
            listBox1.Items.AddRange(array);

        }
Mitja Bonca 557 Nearly a Posting Maven
catch(Exception ex)
{
    MessageBox.Show(ex.Message,"Error message");
}
Mitja Bonca 557 Nearly a Posting Maven

If you dont use the sign "@" on the beginning of the path`s string, you have to write double back slashes for seperating folder. Example:

string path1 = @"C:\myFoler\myFile.txt";
string path2 = "C:\\myFolder\\myFile.txt";

I hope you see the difference between these two examples.

Mitja

Mitja Bonca 557 Nearly a Posting Maven

as Momerath said:
ThisList.Clear();

Mitja Bonca 557 Nearly a Posting Maven

if you want to read the file from the debuf folder in your current project you simply bind the text file, like:

string startupPath2 = Application.StartupPath + @"\something.txt"; //or maybe without backslash! try it(I am doing this code by my heart).
Mitja Bonca 557 Nearly a Posting Maven

If you want to check if something has happened with the code correctly or not, you better use boolean values. This is a simpe example:

private void GoingIntoMAP()
        {
            string path = @"C:\1\myFile.txt";
            bool bSuccess = MAP(path);
            if (bSuccess)
                MessageBox.Show("An error has occured while reading file: " + path);
            else
                MessageBox.Show("File has beed read successfully."); //but this is not necessary to show, only errors or warnings!
        }

        public bool MAP(string FilePath)
        {
            using (FileStream fs = new FileStream(FilePath, FileMode.Open))
            {
                try
                {
                    //read the file and stuff you want to do!
                    //on the end:
                    return true;
                }
                catch
                {
                    return false;
                }
            }
        }

I hope this explains the concept of catching error.
Do some examples and you will see this is the best way.

Mitja

vedro-compota commented: +++ +1
Mitja Bonca 557 Nearly a Posting Maven

This should do it:
But I am not sure what do you want exactly. Or do you want to put every single number from the file into its own row in the List (like: 1,3,7,9 add evey number to the list seperately), or you want to "join" number from one row (like : 1,3,7,9 join into 1379 and add this number to the list)?

This is the code:

FileStream aFile = new FileStream("SomeData.txt", FileMode.Open);
            List<NewList> Numbers = new List<NewList>();
            using (StreamReader sr = new StreamReader(aFile))
            {
                while (!sr.EndOfStream)
                {
                    string line = sr.ReadLine();
                    //1.Putting every number into its own row in the list<T>:
                    string[] array = line.Split(',');
                    for (int i = 0; i < array.Length; i++)
                        Numbers.Add(array[i].ToString()); //you can remove ToString() method if not needed

                    //2.Putting all number into one row (removing commas from original):
                    if (line.Contains(','))
                    {
                        line = line.Replace(",", "");
                        Numbers.Add(line);
                    }
                }
            }

If this is not it, please exaplin a bit better what exactly would you like to do with the numbers, ok?
Mitja

Mitja Bonca 557 Nearly a Posting Maven

If you only want array of integers to sort, you can do:

public static void bubbleSort(ref int[] a)
        {
            Array.Sort(a);
        }
GoogleEyedBass commented: Thanks +0
Mitja Bonca 557 Nearly a Posting Maven

I did my own code for comparing multidimensional array. And it works, at least as far as I was testing. Let me know what you thing:

bool bIsEqual = true;
            string[,] array1 = new string[,] { { "A", "B" }, { "C", "D" } };
            string[,] array2 = new string[,] { { "A", "E" }, { "C", "D" } };
            for (int i = 0; i < array1.GetLength(0); i++)
            {
                int loop2 = 0;
                if (!bIsEqual)
                    break;
                for (int j = 0; j < array2.GetLength(0); j++)
                {
                    loop2++;
                    string A = array1[i, j];
                    string B = array2[i, j];
                    if (A != B)
                    {
                        bIsEqual = false;
                        break;
                    }
                    if (loop2 == 2)
                        break;
                }
            }
            if (!bIsEqual)
                Console.WriteLine("Arrays are not equal");
            else
                Console.WriteLine("Arrays are equal");
            Console.ReadLine();

Mitja

Mitja Bonca 557 Nearly a Posting Maven

You can use Enumerable.SequenceEqual method:

static void Main(string[] args)
        {
            var a1 = new int[] { 1, 2, 3 };
            var a2 = new int[] { 1, 2, 3 };
            var a3 = new int[] { 1, 2, 4 };
            var x = a1.SequenceEqual(a2); // true
            var y = a1.SequenceEqual(a3); // false
        }

Hope it helps,
Mitja

Mitja Bonca 557 Nearly a Posting Maven
Mitja Bonca 557 Nearly a Posting Maven

If this is the error, that means that one of 2 arrays (array[0] or array[1]) but mostly would be array[1] cannot get filled, becuase there is no data for it. Thats means that in the "line" there was no comma (,) and the string couldnt get splitted. There is only one string - but the adding code requires 2 strings.

Please check your file, if there is a comma on EVERY single line.
And please put a break point to go through the code line by line. And tell me exactly when this error occures (which line is in that moment in the streamReader).

Break point is thta red dot, which you put it by clicking on the far left side of the text editor. When code comes to break point, go with pressing F11 line by line.

kvprajapati commented: Very helpful!!! +11
Mitja Bonca 557 Nearly a Posting Maven

Try something like this:

public partial class Form1 : Form
        {
            private Graphics g1;

            public Form1()
            {
                InitializeComponent();

                pictureBox1.Image = new Bitmap(500, 500);
                g1 = Graphics.FromImage(this.pictureBox1.Image);
                Pen gridPen = new Pen(Color.Black, 2);
                g1.DrawLine(gridPen, 0, 0, 100, 100);
            }
        }

... and read it here for some more info: http://www.questionhub.com/StackOverflow/4095260

Mitja Bonca 557 Nearly a Posting Maven

This connection string was only an example Please take a look at your own string. I dont know what it like.

Mitja Bonca 557 Nearly a Posting Maven

As said....
one more thing, the parameter you want to pass to the sql query its not good to use in the query it self. Its better to "attach" it to the sqlCommand,m like this:

try
            {
                //Opening the sql connection and using custom sql statements
                SqlConnection conn = new SqlConnection("Data Source=DEWALD-PC;Initial Catalog=LogbookDatabase;Persist Security Info=True;User ID=sa;Password=123");
                String query = String.Format("SELECT * FROM " + currentYearLbl.Text + " WHERE Pending = @myPending");
                SqlCommand cmd = new SqlCommand(query, conn);
                cmd.Parameters.Add("@myPendings", SqlDbType.VarChar, 50).Value = jobsPendingToolStripMenuItem;
                SqlDataAdapter dap = new SqlDataAdapter(cmd);
                DataTable dt = new DataTable();
                dap.Fill(dt);
                dataGridView1.DataSource = dt;
            }
            catch (Exception err)
            {
                MessageBox.Show("Unable update datagridview" + err);
            }
kvprajapati commented: parameter is good practice. +11
Mitja Bonca 557 Nearly a Posting Maven

This will do (use key up event)

private void button1_KeyUp(object sender, KeyEventArgs e)
        {
            if (e.KeyCode == Keys.Enter)
            {
                this.Close();
            }
        }
Mitja Bonca 557 Nearly a Posting Maven

Come around every time you will encounter the problem. I was in the same position as you 2 years ago. :)

btw: if you get what you have wanted, please mark the thread as salved, so every one who is looking for a similar issue can get the answer.
And one more thing: Ask one thing at ones, if there is another bothering you, pleaser start another thread.

best regards,
Mitja

james6754 commented: Thanks +1
Mitja Bonca 557 Nearly a Posting Maven

tables with _Address are not even needed. Unless if you specificly dont need them. But I would inclued them into the main tables (like address of the doctors, you can easily include in Doctors table).

One thing you can seperate is Patient. YOu dont need to seperate 2 types of them, but the main information about patient and details, like:

Patients: id, gender, name, lastname, birthday, telephones ...
P.Details: all other info which will be fulfiled afterwards when client is in hospital (and later on).

And you can include one more table, thats Billing! Finances are very important part here.

ddanbe commented: Very good effort for all your posts in this thread :) +8
Mitja Bonca 557 Nearly a Posting Maven

Do you have this namespace in the References (Solution explorer tab)?
Otherwise you can try with writing the full path:

System.Windows.Forms.MessageBox.Show("buuu");
Mitja Bonca 557 Nearly a Posting Maven

Ok, lets define, you have Form1 and Form2. Form1 is Main Form, Form2 is Info.

Which one you call in Program.cs (Application.Run(XXXX)); - xxxx is from1 or form2?

This is how you should have:
in application.Run method you have to call Form1 (so the main form, not the intro). Before the form shows, you call Form2 with a timer (when timer comes, form1 closes as well and then opens form1.

There is another way, even better - this is the use of keyword "using" arround the application.start.
The code would look like:

//Form1 (Main Form):
        static void Main()
        {
            Application.EnableVisualStyles();
            Application.SetCompatibleTextRenderingDefault(false);
            using (Form2 form2 = new Form2())
            {
                if (form2.ShowDialog() == DialogResult.OK)
                    Application.Run(new Form1());
            }
        }

//Form2 (Info):
public partial class Form2 : Form
    {
        Timer timer1;
        public Form2()
        {
            InitializeComponent();
            timer1 = new Timer();
            timer1.Interval = 10000;
            timer1.Tick += new EventHandler(timer1_Tick);
            timer1.Start();
        }

        private void timer1_Tick(object sender, EventArgs e)
        {
            timer1.Stop();
            DialogResult = DialogResult.OK;
        }
    }

Simple and useful - I hope you like it.

bye, bye
Mitja

charqus commented: thanks +1
Mitja Bonca 557 Nearly a Posting Maven

crishjeny:
STOP wtih such unproductive posts! We all know that!
Its better not to post posts like this in here.

I have already warned you...
Mitja

Mitja Bonca 557 Nearly a Posting Maven

You can convert DateTime value to an integer, to get the hour and minutes seperated values. And then use them to compare to the hours which defines to when you say good morning and afternoon.

DateTime time = DateTime.Now;
            int hour = time.Hour;
            int minutes=time.Minute;
            if (hour <= 12)
                Console.WriteLine("Good morning");
            else if (hour >= 12 && minutes >= 1)
                Console.WriteLine("Good afternoon");
            Console.ReadLine();

Hope it helps,
Mitja

Mitja Bonca 557 Nearly a Posting Maven

I agree with Hyperion.
This is us getting no where. I assume everyone of us is so inteligent these days, that can use "The google wonder" to find the code, which would make his life easier.
We are here to help ppl with their own specific issues, and I am willing to help them with my best efforts. I expect the same from all of you who are answering here.
What concers the thread creator, prayag.419:
If you want some help from us, please give us some more info about your project. Maybe some of the code where you have issues, or at least explain precisly what would you like to do, in case if you have nothing to give us. We cannot only assume what would you like, ok?

So please show us some good will.
regards,

Mitja

ddanbe commented: Good advice +8
Mitja Bonca 557 Nearly a Posting Maven

What happens? Nothing. It will not set it! Thats why its better to avoid such coding (as I explained up there). Its better to use code, and let user know that the (in your example) id is not long enough.

Im glad I can help,
bye
Mitja

Mitja Bonca 557 Nearly a Posting Maven

This is an example where is shown everything you need. I did it only for you:
... I hope you like it, note: do a copy/paste to CONSOLE application, and try to run it!

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace Okt17GetSet
{
    class Program
    {
        List<StudentInfo> studentList = new List<StudentInfo>();

        static void Main(string[] args)
        {
            bool bChecking = false;
            Program pro = new Program();
            Console.WriteLine("Hi there,");
            while (!bChecking)
            {
                Console.WriteLine("Do you want to ADD new or SEARCH for the student?");
                Console.WriteLine("(1 - add, 2 - search, 3 - exit program)");
                string strQuestion = Console.ReadLine();
                if (strQuestion != null)
                {
                    if (strQuestion == "1")
                        pro.AddingStudent();
                    else if (strQuestion == "2")
                        pro.GettingStudent();
                    else if (strQuestion == "3")
                        bChecking = true;
                    else
                    {
                        Console.WriteLine("Wrong answer, please do it again...");
                        continue;
                    }
                }
            }
            Console.WriteLine("bye, bye...");
            System.Threading.Thread.Sleep(1000);
            Environment.Exit(0);
        }

        private void AddingStudent()
        {
            bool bChecking = false;
            string strID = null;
            string strName = null;

            while (!bChecking)
            {
                Console.WriteLine("Please, insert students ID:");
                strID = Console.ReadLine();
                if (strID.Length >= 6)
                {
                    while (!bChecking)
                    {
                        Console.WriteLine("Please insert student`s name:");
                        strName = Console.ReadLine();
                        if (strName.Contains(" "))
                            bChecking = true;
                        else
                            Console.WriteLine("Student needs to have name and last name...");
                    }
                }
                else
                {
                    Console.WriteLine("Student`s ID is not long enough, it must be at least 6 characters...");
                }
            }
            //when all ok, do an insertion into list of students:
            //1. ADDING NEW STUDENT:
            StudentInfo info = new StudentInfo();
            info.StudentID = strID;
            info.Name = strName;
            studentList.Add(info);

            Console.WriteLine("New student data saved into list!");
            Console.WriteLine("ID: {0}, NAME: …
ddanbe commented: Nice effort. +8
Mitja Bonca 557 Nearly a Posting Maven
shibin09 commented: thanx +0
Mitja Bonca 557 Nearly a Posting Maven

1. My namespace is called "MyNameSpace". So...
How to create that Form3 will inherit from Form2, which is already a child of Form1 (Form2 has class: public partial class Form2 : Form)

I would like to creat like: class Form3 : Form2

And do not forget, all are windows forms.

Is this how it goes:

public partial class Form3 : MyNameSpace.Form2

2. I would like to know something more:
How to pass values from Form2 to Form3 then?

I have some binary data in my variable "buffer, so how do I transfer them to Form3 and because inside its a text, how ten to put this text into a richTextBox?

This is my variable I have now in Form2:

byte[] buffer = (byte[])cmd1.ExecuteScalar();

As said, "buffer" has binary data insed, which I want to transfer to Form3 and show the data (its a text file) in richTextBox.
Any idea?