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

This should do it:

//on form1:

Form2 f2 = new Form2(this);
form2.Show();

//create a method and a label on Form1
//to pass data from form2 to form1;
public void MyMethod(string value)
{
  Label lablel1 = new Label1;
  label1.Location = new Point(10,10);
  this.Controls.Add(label1);
  label1.Text = value;
}

//on form2:
//constructor
public Form2(Form1 _f1)
{
form1 = _f1;
}
Form1 form1;

private void Button_Click(object sender, EventArgs e)
{
 form1.MyMethod(textBox1.Text);
}
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

This should work:

public enum Options
        {
            newZ = 1,
            display,
            Exit
        }

        void Method2()
        {
            string volString = "1";            
            Options options = (Options)Enum.Parse(typeof(Options), volString);
            switch (options)
            {
                case Options.newZ:
                    {
                        break;
                    }
            }
        }
Mitja Bonca 557 Nearly a Posting Maven

Here you have simple examples of using StreamWriter, which is in your case by far best object to use.
And here you can read about StreamWriter class. Its good to know which metods and properties to use with this object.
Hope it helps,
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

What do you means with using SQL? Sql has nothing do to with programming. Its only meant for saving some data, which can be retreived and processed by the program. But not with sql.
Sql is so called dataBase to which you can approach with many kind of quieries (select, insert, update, delete).
So please (as written above), please provide us some more useful inforamtion about what are you really trying to do.

Mitja

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

This is partly true (decimals will not go through, while negative integers will go):

try
{
    numberToFactoral = int32.parse(textbox1.text);
}
catch
{
     label1.text = "please input positive whole number";
     return;

}

If the user will enter "-1" will go through try block. Because its -1 is still a "full number". but this will do:

int value = int.Parse(textBox1.Text);
            if(value<0)
                label1.text = "please input positive whole number";
Mitja Bonca 557 Nearly a Posting Maven

LOL - short answer on so many questions - so dont expect us to be generous with answers!!


This is a stored procedure you have, that`s all? That will do nothing.
What you need to do:
- get the last id existed from the databse
- then you need for every new insertion add +1 (so you have a new id)
- and a stored procedure must be something like:

ALTER PROCEDURE NameOfStoredProcedure
(
@id int,
@name varchar (50)
)
AS
BEGIN
"INSERT INTO tblEventType VALUES(@id, @name)"
END

This kind of s.p. will insert only one row.

Mitja Bonca 557 Nearly a Posting Maven

Do you have to save only names of th checkBoxes? or What exactly? And where? Do you need a new ID (primary key) for each checklistBox? How does your storedProcedure look like (it only accepty one value at a time, or..)?

If its in any help:

private void GetCheckedItems()
        {
            List<string> list = new List<string>();
            foreach (string item in checkedListBox1.CheckedItems)
                list.Add(item);
            BindCBL(list);
        }

        private void BindCBL(List<string> list)
        {
            SqlConnection con = new SqlConnection("connectionString");
            SqlCommand cmd = new SqlCommand();
            cmd.CommandType = CommandType.StoredProcedure;
            cmd.CommandText = "usp_displayeventtype";
            cmd.Connection = con;
            cmd.Connection.Open();
            foreach (string item in list)
            {
                cmd.Parameters.Add("@variableNameFromStoredProcedure", SqlDbType.VarChar, 50).Value = item;
                cmd.ExecuteScalar();
            }
            cmd.Connection.Close();
        }

PS: as I told you I need more info. Its hard to tell you what exactly do you need.

Mitja Bonca 557 Nearly a Posting Maven

You can even shortan the code (like ddanbe proposed):

private void button1_Click(object sender, EventArgs e)
        {
            string[] values = new string[] { textBox1.Text, textBox2.Text };
            int allRows = dataGridView1.Rows.Count;
            if (values[0] != String.Empty || values[1] != String.Empty)
            {
                dataGridView1.Rows.Add(values);
                textBox1.Text = "";
                textBox2.Text = "";
            }
        }
Mitja Bonca 557 Nearly a Posting Maven

Apparently you add data to dgv control from textBoxes. Every time you insert something into textBoxes, these data (2) have to insert into a new row in dgv.
This is how you do it:

public partial class Form1 : Form
    {
        public Form1()
        {
            InitializeComponent();
            dataGridView1.Columns.Add("col1", "column 1");
            dataGridView1.Columns.Add("col2", "column 2");
            dataGridView1.AllowUserToAddRows = false;
        }

        private void button1_Click(object sender, EventArgs e)
        {
            string a = textBox1.Text;
            string b = textBox2.Text;
            int allRows = dataGridView1.Rows.Count;
            if (a != String.Empty || b != String.Empty)
            {
                dataGridView1.Rows.Add(a, b);
                textBox1.Text = "";
                textBox2.Text = "";
            }
        }
    }
Mitja Bonca 557 Nearly a Posting Maven

Forgot to tell you how to retreive dara from Dictonary object:

//to show whats is in Directory you do:
            foreach (KeyValuePair<string, string> item in dic)
            {
                string key = item.Key;
                string value = item.Value;
            }

Now you have all you need. I hope you are happy with the code.

PS: The path in the upper post is just my example path. You have to set it your own to the xml file!

Mitja

Mitja Bonca 557 Nearly a Posting Maven

Ok, I have chosen to use a Dictonary, which is a pretty good idea, becuase this object can store keys and their values. So in your case as a key you have "title" and values is "some text".

Here is the code:

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.Xml;

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

        private void Method()
        {
            Dictionary<string, string> dic = new Dictionary<string, string>();
            dic.Add("title", String.Empty);
            dic.Add("description", String.Empty);

            string path = @"C:\1\test14.xml";
            using (XmlTextReader reader = new XmlTextReader(path))
            {
                try
                {
                    string _key = null;
                    while (reader.Read())
                    {
                        switch (reader.NodeType)
                        {
                            case XmlNodeType.Element:
                                {
                                    _key = reader.Name;
                                    break;
                                }
                            case XmlNodeType.Text:
                                {
                                    if (_key == "title" || _key == "description")
                                    {
                                        dic[_key] = reader.Value;
                                    }
                                    break;
                                }
                            case XmlNodeType.CDATA:
                                {
                                    if (_key == "title" || _key == "description")
                                    {
                                        string tagS = "alt=\"";
                                        string tagE = "\"";
                                        int indexS = reader.Value.IndexOf(tagS) + tagS.Length;
                                        int indexE = reader.Value.IndexOf(tagE, indexS) - tagE.Length;
                                        string myText = reader.Value.Substring(indexS, indexE - indexS);
                                        dic[_key] = myText;
                                    }
                                    break;
                                }
                            default:
                                {
                                    break;
                                }
                        }
                    }
                }
                catch { }
            }

            //to show whats is in Directory you do:
            string textToShow = null;
            foreach (KeyValuePair<string, string> item in dic)
            {
                string key = item.Key;
                string value = item.Value;

                //to put all into one string to show later in messageBox:
                textToShow += key.ToUpper() + ": " + value + Environment.NewLine;
            }
            MessageBox.Show("These is …
Mitja Bonca 557 Nearly a Posting Maven

So you want to get these:

<title>CBS News' Logan victim of 'brutal' Egypt attack</title>
      <description>
        <![CDATA[<p><a href="http://today.msnbc.msn.com/id/41607923/ns/today-entertainment/"><img align="left" border="0" src="http://msnbcmedia.msn.com/j/MSNBC/Components/Photo/_new/110215-lara-logan-egypt.thumb.jpg" alt="CBS Correspondent Lara Logan is pictured in Cairo's Tahrir Square moments before she was assaulted in this photograph taken on Friday, Feb. 11." style="margin:0 5px 5px 0" /></a>The correspondent is recovering in a U.S. hospital from a "sustained sexual assault and beating" she suffered while reporting on the tumultuous events in Cairo last Friday.</p><br clear="all" />]]>
      </description>

For the title what is between <title> and </title>
for the description what is between <description> and </description>

Solution: set flags of these marks (<title>, </title>) and use IndexOf method on 1st mark and IndexOf to tget the 2nd mark (beginning and th end of) and then use these two indexes to get the text between those indexes.

If you need any help, let me know, ok?
bye,
Mitja

Mitja Bonca 557 Nearly a Posting Maven

Nothing. Only code looks a bit different. That C# code has nothing to do with DataBase and their types and null or not null values.

Mitja Bonca 557 Nearly a Posting Maven

What exactly would you like to do?
BTW: there are two sentances in the upper xml code. Which one?

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

I am glad you did it. But this was your mistake, I couldnt know that your set the column to type of Number (decimal) in your dataBase.
bye
Mitja

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
Mitja Bonca 557 Nearly a Posting Maven

So you have 2 comboBoxes. 1st is bound to dataSource and 2nd comboBox is populated with some values, regarding on comboBox1 selection.
Which values are these, what is seatNumber variable?
Can you please provide some more code?
thx
mitja

Mitja Bonca 557 Nearly a Posting Maven

I did the example code, and it works fine. I have created two form (form1, and form2). Instead of using dropDownList, I have used ComboBox control - its actually the same, you only change the code so it will suit to your control. Ok here it is:


//form1:

public partial class Form1 : Form
 {
  Form2 form2;

  public Form1()
  {
   InitializeComponent();
   this.StartPosition = FormStartPosition.CenterScreen;
   OpeningForm2();

   this.comboBox1.DataSource = form2.list;
   this.comboBox1.DisplayMember = "name";
   this.comboBox1.ValueMember = this.comboBox1.DisplayMember;
   this.comboBox1.DropDownStyle = ComboBoxStyle.DropDownList;
  }

  private void OpeningForm2()
  {
   form2 = new Form2();
   //location Form2 beside Form1 (on right side):
   int x = Screen.PrimaryScreen.Bounds.Width / 2;
   int y = Screen.PrimaryScreen.Bounds.Height / 2;
   form2.Location = new Point(x, y);
   form2.Show();
  }
 }

//form2:
 public partial class Form2 : Form
 {
  public BindingList<Country> list;

  public Form2()
  {
   InitializeComponent();
   list = new BindingList<Country>();

   this.listBox1.DataSource = list;
   this.listBox1.DisplayMember = "name";
   this.listBox1.ValueMember = this.listBox1.DisplayMember;

   this.textBox1.KeyPress += new KeyPressEventHandler(textBox1_KeyPress);
  }

  private void textBox1_KeyPress(object sender, KeyPressEventArgs e)
  {
   if (e.KeyChar == (char)Keys.Enter)
   {
    string item = this.textBox1.Text.Trim();
    if (item != String.Empty)
    {
     Country c = new Country();
     c.name = item;
     list.Add(c);
     //clearing:
     this.textBox1.Text = "";
     
     
    }
   }
  }
 }

//and additionaly class of Country
 public class Country
 {
  public string name { get; set; }
 }

You can find the whole project HERE.

Code is working like you wanted - when the user inserts some text into textbBox on Form2, the string transfers to generic list <T> which is a binding source of listBox (on form2) and comboBox …

Mitja Bonca 557 Nearly a Posting Maven

I did an example for you. I didnt use a xml file, but I did my own code of filling dataTable - which is dataSource to the dataGridView - but dont be scared - my point in the code is to show how to look for the value in dgv. The code loops through all the rows and column. And if the value is found, it colors blue (cell becomes selected).

As said, dont get frustrated if you see the dgv bound to the dataSaource (of bindingSourc of dataTable). The looking code is seperated from it. It manually checkes dgv.

namespace Feb15GroupControls
{
    public partial class Form1 : Form
    {
        BindingSource bs;
        DataTable table;       
        public Form1()
        {
            InitializeComponent();
            bs = new BindingSource();
            bs.DataSource = CreatingTable();
            dataGridView1.DataSource = bs;

            dataGridView1.AutoGenerateColumns = true;
            dataGridView1.RowHeadersVisible = false;
            dataGridView1.AllowUserToAddRows = true;
        }

        private DataTable CreatingTable()
        {
            table = new DataTable("myTable");
            table.Columns.Add(new DataColumn("id", typeof(int)));
            table.Columns.Add(new DataColumn("name", typeof(string)));
            table.Columns.Add(new DataColumn("age", typeof(int)));

            Customer[] customers = new Customer[] { new Customer(1, "Mitja Bonca", 31), 
                                                    new Customer(2, "John Johnson", 22), 
                                                    new Customer(3, "Karmen Glenn", 22) };
            DataRow dr;
            for (int i = 0; i < customers.Length; i++)
            {               
                dr = table.NewRow();
                dr["id"] = customers[i].id;
                dr["name"] = customers[i].name;
                dr["age"] = customers[i].age;
                table.Rows.Add(dr);
            }
            return table;
        }

        private void FilteringData(string myValue)
        {
            foreach (DataGridViewRow row in dataGridView1.Rows)
            {
                foreach (DataGridViewCell cell in row.Cells)
                {
                    if (cell.FormattedValue.ToString() != String.Empty)
                    {
                        if (cell.Value.ToString() == myValue)
                            cell.Selected = true;
                        else
                            cell.Selected = false;
                    }
                    else
                        cell.Selected = false;
                }
            }             
        }


        private …
Mitja Bonca 557 Nearly a Posting Maven

You said that dataset is a dataSource of dgv, right? Why dont you look in the dataSet?
Check here for solution:
- http://msdn.microsoft.com/en-us/library/Aa325591
- http://msdn.microsoft.com/en-us/library/det4aw50.aspx

Mitja Bonca 557 Nearly a Posting Maven

2. To loop through all controls, and if textBox is found, do something:

private void button2_Click(object sender, EventArgs e)
        {
            foreach (Control c in Controls)
            {
                if (c is TextBox)
                    c.Text = String.Empty;
            }
        }
Mitja Bonca 557 Nearly a Posting Maven

1. You can create an array of all wanted textBoxes:

private void button1_Click(object sender, EventArgs e)
        {
            TextBox[] tb = new TextBox[] { textBox1, textBox2, textBox3, textBox4, textBox5 };
            for (int i = 0; i < tb.Length; i++)
                tb[i].Text = String.Empty;
        }
Mitja Bonca 557 Nearly a Posting Maven

Here you do:

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

        private void button1_Click(object sender, EventArgs e)
        {
            BLL bll = new BLL();
            List<Customer> list = bll.GetCustomers_BLL();
            this.listBox1.DataSource = list;
            this.listBox1.DisplayMember = "name";
            this.listBox1.ValueMember = this.listBox1.DisplayMember;
        }
    }

    public class BLL
    {
        DAL dal;
        public BLL()
        {
            dal = new DAL();            
        }

        public List<Customer> GetCustomers_BLL()
        {
            return dal.GetCustomers_DAL();
        }
    }

    public class DAL
    {
        public List<Customer> GetCustomers_DAL()
        {
            List<Customer> list = new List<Customer>();          
            using (SqlConnection sqlConn = new SqlConnection("ConnectionString"))
            {
                string query = @"SELECT Name FROM Customers";
                SqlCommand cmd = new SqlCommand(query, sqlConn);
                using (SqlDataReader reader = cmd.ExecuteReader())
                {
                    while (reader.Read())
                    {
                        Customer c = new Customer();
                        c.name = (string)reader[0];
                        list.Add(c);
                    }
                }
            }
            return list;
        }
    }

    public class Customer
    {
        public string name { get; set; }
    }
}

Hope it helps,
Mitja
Mitja Bonca 557 Nearly a Posting Maven

..., but the selection doesn't change from date picker only! I need an object that I can be able to choose both date and time.

Can you please elaborate this issue a bit precisly?

and this works:

DateTime date = dateTimePicker1.Value;
string strDate = String.Format("{0:MM/dd/yy hh:mm tt}", date);

thx,
Mitja

Mitja Bonca 557 Nearly a Posting Maven

Here you can find all your questiuons, if you mean to with with db: http://lamahashim.blogspot.com/2010/04/c-read-insert-update-delete-from-sql.html

Mitja

Mitja Bonca 557 Nearly a Posting Maven

Yes and?
Where from, the store, from the hill or from dataBase?
Please privide us some more info. I cannot know what exactly do you hae in mind.
Mitja

Mitja Bonca 557 Nearly a Posting Maven
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace Feb15StingArray
{
    class Program
    {
        char[] alphabet = "abcdefghijklmnopqrstuvwxyz".ToCharArray();
        string[] lines = System.IO.File.ReadAllLines(@"C:\1\test4.txt");
        string[] parts = null;

        static void Main(string[] args)
        {
            Program one = new Program();
            one.splitData();
            one.run(one.parts);
            Console.WriteLine(one.getValueForName("s"));
            Console.WriteLine("Press any key to exit.");
            System.Console.ReadKey();
        }
        public void run(string[] array)
        {
            foreach (string line in array)
            {
                Console.WriteLine(getValueForName(line));
            }
        }
        public void splitData()
        {
           List<string>list = new List<string>();        
            foreach (string line in lines)
            {
                parts = line.Split(',');
                for (int i = 0; i < parts.Length; i++)
                    list.Add(parts[i]);
            }
            list.Sort();
            parts = null;
            for (int i = 0; i < list.Count; i++)
            {
                Array.Resize(ref parts, i + 1);
                parts[i] = list[i];
            }
        }

        public int getValueForName(string name)
        {
            int totalvalue = 0;
            name = name.Trim();
            char[] namechar = name.ToCharArray();

            foreach (char c in namechar)
            {
                totalvalue += getCharValue(c);
            }
            return totalvalue;
        }

        public int getCharValue(char character)
        {
            int charvalue = 0;
            for (int x = 0; x < alphabet.Length; x++)
            {
                if (character.ToString() == alphabet[x].ToString())
                {
                    charvalue = x + 1;
                    break;
                }
            }
            return charvalue;
        }
    }
}
Mitja Bonca 557 Nearly a Posting Maven

lol
use TeamViewer.

Mitja Bonca 557 Nearly a Posting Maven

Where do you have defined "ShortName" property in the clsItemsNumID class? I dont see it.
Do it this way:

public class clsItemsNumID
    {
        public string LongName { get; set; }
        public string ShortName { get; set; }
        public int ID { get; set; }
        
        public clsItemsNumID(int _id, string _long, string _short)
        {
            this.ID = _id;
            this.LongName = _long;
            this.ShortName = _short;
        }
     }

Now you can set the DisplayMember (LongName) and ValueMember (ones ID, other time ShortName).
It has to work.
Mitja

Mitja Bonca 557 Nearly a Posting Maven

I did a semple code how to position forms. This code bellow shows how to position a new form to all four corners of the mainForm:

namespace Feb13Exercise
{
    public partial class Form1 : Form
    {
        public Form1()
        {
            InitializeComponent();
            this.comboBox1.DropDownStyle = ComboBoxStyle.DropDownList;
            string[] array = { "top-left", "top-right", "bottom-left", "bottom-right" };
            this.comboBox1.Items.AddRange(array);
        }

        private void comboBox1_SelectedIndexChanged(object sender, EventArgs e)
        {
            if (this.comboBox1.SelectedIndex > -1)
            {
                string value = this.comboBox1.GetItemText(this.comboBox1.SelectedItem);
                if (value != String.Empty)
                {
                    Form2 f2 = new Form2();
                    f2.Size = new Size(250, 150);
                    int[]xy = CalculateFormPosition(value, f2.Size.Width, f2.Size.Height);
                    f2.StartPosition = FormStartPosition.Manual;
                    f2.Location = new Point(xy[0], xy[1]);
                    f2.Show(this);
                }
            }
        }

        private int[] CalculateFormPosition(string value, int f2Width, int f2Height)
        {
            int dev = 20;
            int x = this.Location.X;
            int y = this.Location.Y;
            switch (value)
            {
                case "top-left":
                    {
                        x = x + dev;
                        y = y + dev + dev;
                        break;
                    }
                case "top-right":
                    {
                        x = (x + this.Width - dev) - f2Width;
                        y = y + dev + dev;
                        break;
                    }
                case "bottom-left":
                    {
                        x = x + dev;
                        y = (y + this.Height - dev) - f2Height;
                        break;
                    }
                case "bottom-right":
                    {
                        x = (x + this.Width - dev) - f2Width;
                        y = (y + this.Height - dev) - f2Height;
                        break;
                    }
            }
            return new int[] { x, y };
        }
    }
}
Mitja Bonca 557 Nearly a Posting Maven

.I want to appear the new window at the right side lower corner in combo box.

You have a mainForm. And then you have a comboBox on it. And when you select an item from it, a new form has to appear in the button-right corner, with some info in it. Am I correct?

Mitja Bonca 557 Nearly a Posting Maven

Have you checked here? http://msdn.microsoft.com/en-us/library/7a2f3ay4(v=vs.80).aspx

You need to create a boolean (type of volatile) and using it, you can then stop the thread.

NewOrder commented: Thanks. you helped me +0
Mitja Bonca 557 Nearly a Posting Maven

Yes it is, but you can pass it between classes as parametes, or directly if you mark is as public.

Example:

public class Class1
    {
        private string variable1;


        public Class1()
        {
             //constructor of class1
        }

        private void MethodInClass1()
        {           
            variable = "a1";
            Class2 c2 = new Class2();
            c2.var2 = "b2"; //if you set the variable as public, you can access it directly (but this is a bad practice).
            c2.MethodInClass2(variable1);
            
        }
    }

    public class Class2
    {       
        private string var1;
        public string var2;
        
        public Class2()
        {
            //constructor of class2
        }

        public void MethodInClass2()
        {
            MessageBox.Show("2. " + var1 + " AND " + var2);
        }
    }

You can pass the params in the constructor of the class well:

public class Class1
    {
        private string variable1;


        public Class1()
        {
             //constructor of class1
        }

        private void MethodInClass1()
        {           
            variable = "a1";
            Class2 c2 = new Class2(variable1);
            
        }
    }

    public class Class2
    {       
        private string var1;       
        
        public Class2(string value)
        {
            //constructor of class2
            var1 = value;
            MethodInClass2();
        }

        public void MethodInClass2()
        {
            MessageBox.Show("2. " + var1 + " AND " + var2);
        }
    }
Mitja Bonca 557 Nearly a Posting Maven

As said, you have to create your own form, which will look like a messageBox. There you can do what ever you want.

Mitja Bonca 557 Nearly a Posting Maven

Me neither :)
List<T> is best option. Maybe for some "simple" arrays its better to use a simple array, like string[], or int[]. But if you have a custom object, List is better choice, and even better is a generic list (List<T> - as Momerath described in the previous post).

Mitja Bonca 557 Nearly a Posting Maven

This is the game you want I guess:

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 Feb09Exercise3
{
    public partial class Form1 : Form
    {
        Random random = new Random();
        int allButtons;
        public Form1()
        {
            InitializeComponent();
            foreach (Control c in Controls)
            {
                if (c is Button)
                {
                    c.Click += new EventHandler(c_Click);
                    allButtons++;
                }
            }
            RandomText();        
        }

        private void c_Click(object sender, EventArgs e)
        {
            Button b = sender as Button;
            string strText = b.Text;
            if (strText != String.Empty)
            {
                string items = GetAdjacents(b.Name);
                string[] values = items.Split(',');

                string[] free = null;
                int counter = 0;               
                for (int i = 0; i < values.Length; i++)
                {
                    string name = "button" + values[i];
                    foreach (Control c in Controls)
                    {
                        if (c is Button)
                        {
                            if (c.Name == name && c.Text == String.Empty)
                            {
                                counter++;
                                Array.Resize(ref free, counter);
                                free[counter - 1] = name;
                            }
                        }                        
                    }
                    //FINAL DECISION OF THE NEW RE-LOCATION (using random selection between those places which are free (empty):
                    if ((i + 1) == values.Length)
                    {
                        string item = GetRandomReLocation(free);
                        //var _control = this.Controls.OfType<Button>().Where(c => c.Name == item);
                        (Controls[item] as Button).Text = strText;
                        b.Text = String.Empty;
                    }
                }
            }
        }

        private string GetRandomReLocation(string[] array)
        {
            string item = null;
            try
            {
                item = array[random.Next(0, array.Length)];                
            }
            catch { MessageBox.Show("Some error occured... simply continue!"); }
            return item;
        }

        private void RandomText()
        {
            Button[] buttons = new Button[] { button1, button2, button3, button4, button5, button6,
                                              button7, button8, button9, button10, button11, button12, 
                                              button13, button14, …
Mitja Bonca 557 Nearly a Posting Maven

ups, sorry, and thx for reminding me. I has to be this way:

string column1 = dgv[0,6].Value.ToString();
string column2 = dgv[1,6].Value.ToString();
string column3 = dgv[2,6].Value.ToString();