Mitja Bonca 557 Nearly a Posting Maven

Size is a read only property. Use Width and Height directly, Size is just a helper property if you need them as a Size object.

Form1 f = new Form1();
 f.Height = 400;
Mitja Bonca 557 Nearly a Posting Maven

Yep, dataGridView control will be the best option here.

Mitja Bonca 557 Nearly a Posting Maven

And here is the example (better suitable to you) which using dataTable (dataSet) as dataSoucrce. Take a look how it has to be done. The code automatically removed the item from listBox (becuase it was removed from dataTable and its data bound):

public partial class Form1 : Form
    {
        BindingSource bs;
        DataSet ds;
        public Form1()
        {
            InitializeComponent();
                               
            string[] array = new string[] { "A", "B", "C" };
            ds = new DataSet();
            DataTable table = new DataTable("table1");
            table.Columns.Add(new DataColumn("letters", typeof(string)));
            DataRow dr;
            for (int i = 0; i < array.Length; i++)
            {
                dr = table.NewRow();
                dr["letters"] = array[i];
                table.Rows.Add(dr);
            }
            ds.Tables.Add(table);

            //set datasource:
            bs = new BindingSource();
            bs.DataSource = ds.Tables["table1"];
            listBox1.DataSource = bs;
            listBox1.DisplayMember = "letters";
            listBox1.ValueMember = listBox1.DisplayMember;
            listBox1.SelectedIndex = -1;
        }

        private void button1_Click(object sender, EventArgs e)
        {
            int rowIndex = listBox1.SelectedIndex;
            ds.Tables["table1"].Rows[rowIndex].Delete();
        }
    }

I hope it helps,
Mitja

Mitja Bonca 557 Nearly a Posting Maven

Look at this code how it should be done:

public partial class Form1 : Form
    {
        List<string> list;
        BindingList<string> bindingList;
        public Form1()
        {
            InitializeComponent();
                               
            string[] array = new string[] { "A", "B", "C" };
            list = new List<string>(array);
            bindingList = new BindingList<string>(list);

            listBox1.DataSource = bindingList;
            listBox1.SelectedIndex = -1;
        }

        private void button1_Click(object sender, EventArgs e)
        {
            string item = listBox1.SelectedItem.ToString();
            bindingList.Remove(item);
        }
    }
Mitja Bonca 557 Nearly a Posting Maven

Your are welcome.
What is tabular view?

Mitja Bonca 557 Nearly a Posting Maven

My this code:

while (reader.Read())
{
    if(reader.GetValue(0) != DBNull.Value)
        listAtt.Items.Add(reader.GetValue(0).ToString());
        //or better coding to get value:
        //listAtt.Items.Add((string)reader[0]);
}

This should do it.
Mitja

Mitja Bonca 557 Nearly a Posting Maven

hmm.. dgv is so huge control and there is really a lot to lear if you want to use it and understand its work.
Here you can start learning: http://www.dotnetperls.com/datagridview-tips

Mitja

Mitja Bonca 557 Nearly a Posting Maven

Get, set accessors are great option, becuase you can set it in some place, and retrive (get) it in another. So, even if you dont need it, you can still have it, and use it.
Mitja

Mitja Bonca 557 Nearly a Posting Maven

Hi, and welcome to programming.
About your question, you have to give us an idea of what would you like to do.
Then we`ll help you out.
Mitja

Mitja Bonca 557 Nearly a Posting Maven

I did a mistake, sorry. Take a look ones again into my 1st post.
Mitja

Mitja Bonca 557 Nearly a Posting Maven

You can see into this example code how it has to be done:

public partial class Form1 : Form
    {
        public Form1()
        {
            InitializeComponent();
            Text[]  arrayOfText = new Text[3];
            string[] array = new string[] { "A", "B", "C" };
            
            //Adding int Text Array:
            for(int i=0;i<arrayOfText.Length;i++)
            {
                arrayOfText[i].someText = array[i];
            }

            //reading out of Text Array:
            foreach (Text _text in arrayOfText)
            {
                string myText = _text.someText;
            }
        }
    }

    public struct Text
    {
        public string someText { get; set; }
    }

and I hope it helps,
Mitja

Mitja Bonca 557 Nearly a Posting Maven

Yes you do:

if(dataGridView1.Rows.Count > 0)
{
   //your code
}
AngelicOne commented: thanks +1
Mitja Bonca 557 Nearly a Posting Maven

Btw, jsut in case:
that you would wonder where to get File class (add a new namespace: System.IO).
Mitja

Mitja Bonca 557 Nearly a Posting Maven

Hi,
You can use StreamReader to read rows, and the code will look like this:

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

        private void button1_Click(object sender, EventArgs e)
        {
            List<string> list = GetDataFromFile();
            richTextBox1.Clear();

            foreach (string item in list)
                richTextBox1.AppendText(item + Environment.NewLine);
        }

        private List<string> GetDataFromFile()
        {
            List<string> list = new List<string>();
            string tag = "[HRData]";
            bool bGetText = false;
            string path = @"C:\1\test17.txt";
            using (StreamReader sr = new StreamReader(path))
            {
                string line;
                while ((line = sr.ReadLine()) != null)
                {
                    if (bGetText)
                        list.Add(line);
                    else if (line == tag)
                        bGetText = true;
                }
            }
            return list;
        }
    }

The problem is, especially if you want to show numbers in some kind of columns, a better idea would be to use a datagriview - to seperate numbers. This is just an idea.

Mitja

Mitja Bonca 557 Nearly a Posting Maven

I will only add to ddanbe` post:
If you are not in some dgv`s event handler you get the row number like:

private void dataGridView1_CellClick(object sender, DataGridViewCellEventArgs e)
        {
            int rowIndex1 = e.RowIndex;
            int rowIndex2 = GetRowIndex();
        }

        private int GetRowIndex()
        {
            int rowIndex = this.dataGridView1.CurrentCell.RowIndex;
            return rowIndex;
        }

Mitja

ddanbe commented: Thanks for the addition! +8
Mitja Bonca 557 Nearly a Posting Maven

Why would you have drives in seperated combo? Wouldn`t be better to have all in treeView?

Mitja Bonca 557 Nearly a Posting Maven

For login ordinary we have userName and password. So for checking if user exist in the database you only chack for these 2 parameters.

So:

SELECT UserName, Password FROM Users WHERE UserName = 'textBoxUserName.Text'

Now you open an sqlDataReader which wil check if the userName exists.
If exists you compare the Password of this user from the database, with the one from textBoxPassword.Text.
If passwords are equal, login is successful
If not password is incorrect.

If even userName does not exist in the dataBase, login data from textBoxes are completely off.
This is how you do the login checking!

Hope it helps.

PS: here is the full code for login:

public static bool LogingInMethod(string userName, string password)
        {
            bool result = false;

            string sqlQuery = "SELECT UserName, Password FROM Users WHERE UserName ='" + userName + "'";
            using (SqlConnection sqlConn = new SqlConnection(p))
            {
                SqlCommand cmd = new SqlCommand(sqlQuery, sqlConn);
                SqlDataReader reader;
                bool bHasRows = false;
                try
                {
                    sqlConn.Open();
                    reader = cmd.ExecuteReader();
                    if (reader.HasRows)
                    {
                        while (reader.Read())

                            if (password == reader["Password"].ToString().Trim())
                            {
                                result = true;
                                break;
                            }
                        bHasRows = true;
                    }
                    reader.Close();
                }
                catch (System.Exception ex)
                {
                    MessageBox.Show(ex.Message);
                    sqlConn.Close();
                }
                finally
                {
                    if (sqlConn.State == ConnectionState.Open)
                    {
                        sqlConn.Close();
                    }
                    cmd = null;
                    reader = null;
                    GC.Collect();
                }

                if (result == true)
                {
                    result = true;
                }

                else if (bHasRows == false)
                {
                    MessageBox.Show("Wrong userName.", "Eror", MessageBoxButtons.OK, MessageBoxIcon.Error);
                    result = false;
                }
                else
                {
                    MessageBox.Show("Wrong password.", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                    result = …
Mitja Bonca 557 Nearly a Posting Maven

Sure no problem, you simply chenge the code a bit to:

//I will put the names and ages into the list where tick is added:
            foreach (ListViewItem item in listView1.Items)
            {
                if (item.Checked)
                    list.Add("NAME: " + item.Text + " - AGE: " + item.SubItems[1].Text);
            }
Mitja Bonca 557 Nearly a Posting Maven

Here is an example code how to use checkBoxes in listView:

public partial class Form1 : Form
    {
        List<string> list;
        public Form1()
        {
            InitializeComponent();
            listView1.View = View.Details;
            listView1.CheckBoxes = true;
            listView1.Columns.Add("name", 100, HorizontalAlignment.Left);
            listView1.Columns.Add("age", 70, HorizontalAlignment.Center);
            listView1.Columns.Add("country", -2, HorizontalAlignment.Center);

            ListViewItem item1 = new ListViewItem(new string[] { "mitja", "28", "Slovenia" });
            ListViewItem item2 = new ListViewItem(new string[] { "john", "29", "USA" });
            ListViewItem item3 = new ListViewItem(new string[] { "sara", "22", "Germany" });
            listView1.Items.AddRange(new ListViewItem[] { item1, item2, item3 });
        }

        private void button1_Click(object sender, EventArgs e)
        {
            list = new List<string>();
            //I will put the names and ages into the list where tick is added:
            for (int i = 0; i < listView1.Items.Count; i++)
            {
                if (listView1.Items[i].Checked)
                    list.Add("NAME: " + listView1.Items[i].Text + "  -  " + "AGE: " + listView1.Items[i].SubItems[1].Text);
            }
            if (list.Count > 0)
            {
                //showing the names:
                string names = null;
                foreach (string name in list)
                    names += name + Environment.NewLine;
                MessageBox.Show("Selected names are:\n\n" + names);
            }
            else
                MessageBox.Show("No names selected.");
        }
    }[I][/I]
ddanbe commented: Showing great effort. +8
Mitja Bonca 557 Nearly a Posting Maven

1st:
you code of selected item is incorect, you have to check for "Selected" property, not "Checked".

Checked property is especially used for checkBoxes.

Mitja Bonca 557 Nearly a Posting Maven

This how:

public partial class Form1 : Form
    {
        List<string> listNames;
        public Form1()
        {
            InitializeComponent();
              
            //some example data to populare dgv:
            dataGridView1.Columns.Add("col1", "name");
            dataGridView1.Columns.Add("col2", "age");
            dataGridView1.Rows.Add("mitja", "31");
            dataGridView1.Rows.Add("john", "28");
            dataGridView1.Rows.Add("sara", "22");            
        }

        private void button1_Click(object sender, EventArgs e)
        {
            listNames = new List<string>();
            foreach (DataGridViewRow row in dataGridView1.Rows)
            {
                foreach (DataGridViewCell cell in row.Cells)
                {
                    if (cell.ColumnIndex == 0) //SET YOUR PARTICULAR COLUMN INDEX HERE!!
                    {
                        if (cell.FormattedValue != String.Empty)
                            //add a name from 1st column (column with index 0):
                            listNames.Add(cell.Value.ToString());
                    }
                }
            }

            //show ann the names from the list:
            string strNames = null;
            foreach (string name in listNames)
                strNames += name + Environment.NewLine;
            MessageBox.Show("List of all names\n\n" + strNames);
        }
    }
AngelicOne commented: tnx +1
Mitja Bonca 557 Nearly a Posting Maven

Heres all you need:

private void button1_Click(object sender, EventArgs e)
        {
            //changing name and text property of the tabPage1 (of the tabContgrol1):
            tabPage1.Name = String.Empty;
            tabPage1.Text = "LOOK";

            //creating new tabPage (of th tabControl1):
            int countPages = tabControl1.TabPages.Count;
            TabPage newPage = new TabPage();
            newPage.Name = "tabPage" + countPages;
            newPage.Text = "LOOK - NEW TABPAGE";
            tabControl1.TabPages.Add(newPage);
        }

about your last question, answer is Yes.
YOu can edit their properties in the code (in runtime) without any problem. Just be careful, that changes wont influence to the rest of th code (jusr be careful, ok?).
bye
Mitja

Mitja Bonca 557 Nearly a Posting Maven

Hi,
I guess you want to do the sql query on every character inserted, but...
You missed the point of the main issue you are having. Tell me, which characters do you want to be inserted into textBox (or which not)?
As far as I can see from your code there are:
- lettes
- numbers
- why do you need "IsControl" characters? which one do you expect?
- whitespaces

- What about backspace for erasing?

Mitja

Mitja Bonca 557 Nearly a Posting Maven

Convert the value to integer, and you should have the correct value, like:

private void numericUpDown1_ValueChanged(object sender, EventArgs e)
        {
            int value = Convert.ToInt32(this.numericUpDown1.Value);
        }
Mitja Bonca 557 Nearly a Posting Maven

Sorry for the mess, I forgot this code:

if (item != String.Empty)
            {
                DataTable table = GetDataFromDB(item);
                this.comboBox1.DataSource = table;
                this.comboBox1.DisplayMember = item;
                this.comboBox1.ValueMember = item;
            }

PS: DO NOT use listBox.Clear method now!
This has to work
Mitja

Mitja Bonca 557 Nearly a Posting Maven

In form load write:

this.FormBorderStyle = FormBorderStyle.None;
Mitja Bonca 557 Nearly a Posting Maven

Look at this code, it creates and erases (if exist) all labels:

Label[] label;
        int counter = 1;
        private void button1_Click(object sender, EventArgs e)
        {
            //checing if labels already arecreatred:
            if (label != null)
                ClearingLabels();
            
            //next: creating new labels:
            int x = 20;
            int y = 20;
            label = new Label[5];
            for (int i = 0; i < label.Length; i++)
            {
                label[i] = new Label();
                label[i].Location = new Point(x, y);
                label[i].Text = "My label number " + ((i + 1) * counter).ToString();
                this.Controls.Add(label[i]);

                //setting new location for the next label:
                y = y + 25;
            }

            //to check that new labels are created:
            counter++;
        }

        private void ClearingLabels()
        {
            for (int i = 0; i < label.Length; i++)
            {
                label[i].Text = "";
                this.Controls.Remove(label[i]);
            }
            label = null;
        }
Mitja Bonca 557 Nearly a Posting Maven

Hi,
of course its possible to do games with C# -everything you can image.
Here is a link to your game:
http://forum.codecall.net/csharp-tutorials/1804-code-c-tic-tac-toe.html

Hope it helps,
Mitja

yousafc# commented: 10 +0
Mitja Bonca 557 Nearly a Posting Maven

So does it work like you want to?

Mitja Bonca 557 Nearly a Posting Maven

You want to create 20 centances. is there any pre-defined order of the array?
I mean has to code pick one item from 1st array, then one item from 2nd array, one item from 3rd array and one item from 4th array? Or can be custom?

Mitja Bonca 557 Nearly a Posting Maven

You can do it like this:

int[] array = new int[25];
Random random = new Random();
// insert 25 random integers from 0-99 in tree
for ( int i = 0; i < 25; i++ )
{
    int value = random.Next(0,101);
    array[i] = value;
}

//sort in ascending order:
Array.Sort(array);   //array is now sorted in asc

//sort in descending order (if you need it):
Array.Reverse(array); //array is now sorted in asc

Hope it helps,
Mitja

Mitja Bonca 557 Nearly a Posting Maven

Is this what you had in mind:

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

namespace Feb18IntArray_ReadLine
{
    class Program
    {
        static void Main(string[] args)
        {
            int[] array = null;
            int counter = 1;
            Console.WriteLine("Please write numbers (one number each time):");
            Console.WriteLine("(If you want to see all the numbers inserted, press q (to quit))");

            while (true)
            {
                string item = Console.ReadLine();
                if (item != "q")
                {
                    int value = 0;
                    bool bChecking = int.TryParse(item, out value);
                    if (bChecking)
                    {
                        Array.Resize(ref array, counter);
                        array[counter - 1] = value;
                        counter++;
                        Console.WriteLine("Good, next one...");
                    }
                    else
                        Console.WriteLine("This was not a number, please do it again...");
                }
                else
                    break;
            }
            string values = null;
            for (int i = 0; i < array.Length; i++)
                values += array[i].ToString() + " ";
            Console.WriteLine("This are all the values: {0}", values);
            Console.ReadLine();
        }
    }
}
ddanbe commented: Clear code +8
Mitja Bonca 557 Nearly a Posting Maven

You want that user write number by number (one per each time) and the app. should create an array?

Mitja Bonca 557 Nearly a Posting Maven

Here is the code you need;

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;
using System.Data.SqlClient;

namespace Feb18Exercise1
{
    public partial class Form1 : Form
    {
        public Form1()
        {
            InitializeComponent();
            //ATTENTION!
            //MAKE SURE that the names from comboBox are the same as column names in database!
            //otherwise this will not work!
            comboBox1.Items.AddRange(new string[] { "Name", "Surename", "Student number" });
        }

        private DataTable GetDataFromDB(string type)
        {
            DataTable table = new DataTable("StudentDetails");
            using (SqlConnection sqlConn = new SqlConnection("yourConnectionString"))
            {
                string query = @"SELECT '" + type + "' FROM Students";
                SqlCommand cmd = new SqlCommand(query, sqlConn);
                using (SqlDataAdapter da = new SqlDataAdapter(cmd))
                    da.Fill(table);
            }
            return table;
        }

        private void comboBox1_SelectedIndexChanged(object sender, EventArgs e)
        {
            string item = this.comboBox1.GetItemText(this.comboBox1.SelectedItem);
            if (item != String.Empty)
            {
                DataTable table = GetDataFromDB(item);
                this.listBox1.Items.Clear();
                this.comboBox1.DataSource = table;
            }
        }
    }
}

PS: be careful with connection string. It has to be the correct one! I hope you know how to handle with it.
AND: about names in comboBox: now the code will work only in case if the names from comboBox and column in DataBase are the same ("Name", "Surename" "Student number")
HINT: Its good practice to avid using white spaces in the dataBase columns (like Student number, it would a way better be: StudentNumber).
That much... I hope it will help,

Mitja

Mitja Bonca 557 Nearly a Posting Maven

In foreach loop:

List<RangeChecker> range = new List<RangeChecker>();
//then you fill the list!
for(int i = 1; i< 5; i++)
{
    RangeChecker rr = new RangeChecker();
    //i will insert some example data
    rr.Meter = i;
    rr.Yard = (i*0.9)
    range.Add(rr);
}

//read out of it:
foreach(RangeChecker rc in range)
{
    int intMeter = rc.meter;  //reading meter property
    int intYard = rc.yard;    //reading yard property
}

//lets say you have a class RangeChecker with properties:
class RangeChecker
{
    public int meter { get; set; }
    public int yard  { get; set; }
}

Hope it helps explaining how generic list with custom object works
Mitja

aaronmk2 commented: thank you, you helped me with my question and now I understand foreach +1
Mitja Bonca 557 Nearly a Posting Maven

Take a look into Solution Explorer, which forms go you have. Double click on one, that you see the design of each. And righ mouse of each of them and select "View code" to see the code editor. This way it will be easier for you to find out which form is which, and what is has.
Hope it helps,
Mitja

Mitja Bonca 557 Nearly a Posting Maven

No.
So open that form2. We cannot know which one is that your "login Form", can we?

Mitja Bonca 557 Nearly a Posting Maven

And where do you instantiate the object, like:
TBinarySTree bt; ?

You can create a new instance of an object on two ways:

namespace ConsoleApplication1
{
    class MyClass
    {
        //1. in the class:
        BinarySTree bt = new TBinarySTree();
   
        //2.In the method
        BinarySTree bt;
        private void MyMethod()
        {
            bt = new BinarySTree(); //like momerath said!
        }
    }
}
Mitja Bonca 557 Nearly a Posting Maven

You should start avoiding this auto generated dataSets. They suck. I know you are a begginer, but you better get some book and do some basic learning. Otherwise you will stuck here with us for a long time (dont get me wrong, I will still help you, but I only want to help You, to learn some basics - for easier understanding and coding).

ok, you said:
"I have a dropdown box. with "Name" "Surname" and "student number""
Does that mean you have 3 dropDowns or just one? Its really not understandable to me.
Plase explain, then I can go on..
thx
Mitja

Mitja Bonca 557 Nearly a Posting Maven

Hi again,
it would help if you would paste the code that you have in here, it will be a way easier salved.

HINT: ayou said you can bind Names to the listBox, so when you want to bind "SureNames", 1st you set the dataSource to null (to clear it) and then create a new instance of a datasouce and bind it to thw listBox again.

Thx
Mitja

Mitja Bonca 557 Nearly a Posting Maven

hehe, no problem I like to help you guys. I know how its being on the beginning.
cheers,
Mitja

Mitja Bonca 557 Nearly a Posting Maven

hi, i'm having a bit of trouble with grid views. see i can show stuff in them but i want to manipulate and use a certain selected record or field in it ( e.g : delete it from table in the DB or copy it into a textbox.). i'll be so grateful if you could add some code snippets too. thanks guys...

And I would be grateful to read more good info about the issue. You are not clear enough here - so some additional explanation is surely required - if you want any decent help.

Mitja

Mitja Bonca 557 Nearly a Posting Maven

Convert strings into integers and then do the comparison:

int intValueA = Convert.ToInt32(txtMath.Text);
if (ibtValueA >= 80)
yousafc# commented: THIS IS BEST SOLVED +0
Mitja Bonca 557 Nearly a Posting Maven

This should do it:

public partial class Form1 : Form
    {
        public Form1()
        {
            InitializeComponent();
            string[] array ={"A", "B", "C", "D", "E"};
            listBox1.DataSource = array;
            listBox1.SelectedIndex = -1;
            listBox1.SelectedIndexChanged+=new EventHandler(listBox1_SelectedIndexChanged);
        }

        private void button1_Click(object sender, EventArgs e)
        {
            //1. automatic selection - insert the number of the index into textBox
            try
            {
                listBox1.SelectedIndex = int.Parse(textBox1.Text);
            }
            catch { }
            
        }

        private void listBox1_SelectedIndexChanged(object sender, EventArgs e)
        {
            //2. when you select a row in the listBox, the value get written into textBox:
            textBox2.Text = listBox1.GetItemText(listBox1.SelectedItem);
        }
    }
Mr.BunyRabit commented: Easy and Simple. +1
Mitja Bonca 557 Nearly a Posting Maven

Here is an example, that might help:

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 Feb17Exercise
{
    public partial class Form1 : Form
    {
        public Form1()
        {
            InitializeComponent();

            // Create the customer object we want to display
            Customer bill = new Customer();
            // Assign values to the properties
            bill.Age = 50;
            bill.Address = "114 Maple Drive ";
            bill.DateOfBirth = Convert.ToDateTime(" 5.11.1979");
            bill.SSN = "123-345-3566";
            bill.Email = "bill@aol.com";
            bill.Name = "Bill Smith";
            // Sets the the grid with the customer instance to be
            // browsed
            PropertyGrid propertyGrid1 = new PropertyGrid();
            propertyGrid1.Location = new Point(10, 10);
            propertyGrid1.Size = new Size(250, 400);
            this.Controls.Add(propertyGrid1);
            propertyGrid1.SelectedObject = bill;

        }
    }

    [DefaultPropertyAttribute("Name")]
    public class Customer
    {
        private string _name;
        private int _age;
        private DateTime _dateOfBirth;
        private string _SSN;
        private string _address;
        private string _email;
        private bool _frequentBuyer;

        // Name property with category attribute and 
        // description attribute added 
        [CategoryAttribute("ID Settings"), DescriptionAttribute("Name of the customer")]
        public string Name
        {
            get
            {
                return _name;
            }
            set
            {
                _name = value;
            }
        }
        //[Browsable(false)]  !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! <<<< if you use it, it will be excluded from the dataSource!
        [CategoryAttribute("ID Settings"),
        DescriptionAttribute("Social Security Number of the customer")]
        public string SSN
        {
            get
            {
                return _SSN;
            }
            set
            {
                _SSN = value;
            }
        }
        [CategoryAttribute("ID Settings"),
        DescriptionAttribute("Address of the customer")]
        public string Address
        {
            get
            {
                return _address;
            }
            set
            {
                _address = value;
            }
        }        
        [CategoryAttribute("ID Settings"),
        DescriptionAttribute("Date of Birth of the Customer (optional)")]
        public DateTime DateOfBirth
        {
            get
            {
                return …
Mitja Bonca 557 Nearly a Posting Maven

Can you point me to the row where is comes to the error?
Its hard to look in such a code, which has so many custom objects - it will take a lot of time to figure out what all you have there.
thx
Mitja

Mitja Bonca 557 Nearly a Posting Maven

The question is, do you really need a dataSet? Do you have more then one DataTable?
Becuause DataSet is nothing else then a bunch of dataTables.

Some strange code you have there:

sAdapter.Fill(sDs, "OT"); //OT is the DataTable name right?
sTable = sDs.Tables["OT"];

better try this was:

sDs = new DataSet();
DataTable sDt = new DataTable("myDataTable");
sAdapter.Fill(sdt);
sDs.Tables.Add(sDt);
dataGridView1.DataSource = sDs.Tables["myDataTable"];

Hope it helps,
Mitja

Mitja Bonca 557 Nearly a Posting Maven

What I can see from the code you gave me is, that you populate comboBox1 with only 2 valeus (first, business).
Then you have a string array of seat numbers.
QUESTION: With which values would you like to populate comboBox2? All of the seats which are empty?

If so, you should re-write the code completely.
But tell me 1st which values exactly you want to have in comboBox2, when "First" is selected in comboBox1?

Mitja Bonca 557 Nearly a Posting Maven

Is there any other control on the form, you can set its primal focus? If you can try to set the focus to the form:
this.Focus();

Mitja Bonca 557 Nearly a Posting Maven

Use:
c.Enable = false;

if you want to set the control (textBox) not to be editable.

AngelicOne commented: tnx 4 help +1