Mitja Bonca 557 Nearly a Posting Maven

Does the list get filled up?

I asked you how many columns does your DGV have?
my code was made for 2 columns, so if you dont have two (less or more) might be a problem.
You have to get two values into a List<object>, those from two columns (id and name).

Mitja Bonca 557 Nearly a Posting Maven

You ca ndo it this way:

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

        private void button1_Click(object sender, EventArgs e)
        {
            Form3 f3 = new Form3();
            Form2 f2 = new Form2(f3);
            f2.Show();
        }
    }   

//form2:
 public partial class Form2 : Form
    {
        Form3 f3;
        public Form2(Form3 _f3)
        {           
            InitializeComponent();
            f3 = _f3;
        }

        private void button1_Click(object sender, EventArgs e)
        {
            f3 = new Form3();
            f3.Show();
        }
    }
Mitja Bonca 557 Nearly a Posting Maven

And this is the method you have it on Form1:

etDataFromDoctorGridView

right?

So where is the problem? I dont see it, at least if you populate the dataGridView.

How many columns do you have in the dgv? Please, put a break point on dgv_CellClick event, to see whats going on.

Mitja Bonca 557 Nearly a Posting Maven

Show me your code of Form2...

Mitja Bonca 557 Nearly a Posting Maven

@Mitja
What is wrong with StringBuilder and append?

LOL, you dont get it, me and Momerath had some issues in the past, I was constantly using apending string to string. And he then tought me to use StringBuilder instead.
Thx for that Momerath.
Appreciate it.
Mitja

Mitja Bonca 557 Nearly a Posting Maven

maybe a bit off topic..

Momerath: ... StringBuilder!!! :)
dont use any array, or "appanding" a text to a text, like myString +=something!

:)
I have learned that now.

Mitja Bonca 557 Nearly a Posting Maven

Code works fine. I have tested it (becuase I made it by my self).

btw, could you just copy-past the code to your clean project? The only think that C# generates its self is th button click (to open form2).
This one you have to put it on the form and add an event of the Click (and paste the code from my button_click to yours). All other code you just copy-paste.

It has to work.
And btw, where did you find this like of code in mine:

f1.GetDataFromDoctorGridView(data);

My code only has:

f1.GetDataFromForm2(data);
Mitja Bonca 557 Nearly a Posting Maven

Check out this code:

//form1:
public partial class Form1 : Form
    {
        public Form1()
        {
            InitializeComponent();

        }

        private void button1_Click(object sender, EventArgs e)
        {
            Form2 f2 = new Form2(this);
            f2.Show();
        }

        public void GetDataFromForm2(List<object> list)
        {
            textBox1.Text = list[0].ToString();
            textBox2.Text = list[1].ToString();
        }
    }

//form2:
public partial class Form2 : Form
    {
        Form1 f1;
        List<Doctor> list;
        public Form2(Form1 _f1)
        {
            InitializeComponent();          
            this.dataGridView1.CellClick += new DataGridViewCellEventHandler(dataGridView1_CellClick);
            this.f1 = _f1;

            //populate DGV:
            PopulateDoctors();
        }

        private void PopulateDoctors()
        {
            list = new List<Doctor>
            {
                new Doctor{ID=1, Name="Doctor 1"},
                new Doctor{ID=2, Name="Doctor 2"}
            };
            dataGridView1.DataSource = list;
        }

        private void dataGridView1_CellClick(object obj, DataGridViewCellEventArgs e)
        {
            int rowindex = e.RowIndex;
            List<object> data = new List<object>();
            foreach (DataGridViewRow row in this.dataGridView1.Rows)
            {
                if (rowindex == row.Index)
                {                   
                    foreach (DataGridViewCell cell in row.Cells)
                        data.Add(cell.Value.ToString());
                    break;
                }
            }
            //send data to form1:
            f1.GetDataFromForm2(data);
            //close this form2:
            this.Dispose();
        }
    }

    class Doctor
    {
        public int ID { get; set; }
        public string Name { get; set; }
    }

Mitja

Mitja Bonca 557 Nearly a Posting Maven

Depents what type are these different versions. If they are both numbers you can use:
==, >=, <=, >, < (all of them).
If they are a string you cannot use any. Becuase it will simply not work. YOu cannot compare the difference in the string, you can only compare if they are same (or different) lenght, or they are equal (or not); meaning if they are really equal (like: "aaa" == "aaa" > true, "aaa" != "aaa" > false, "aaa" == "aab" > false

You see the difference?
Mitja

Mitja Bonca 557 Nearly a Posting Maven

Check this out:

public Form1()
        {
            InitializeComponent();
            richTextBox1.TextChanged += new EventHandler(richTextBox1_TextChanged);
        }

        private void richTextBox1_TextChanged(object sender, EventArgs e)
        {
            if (richTextBox1.Lines.Length == 4)
                DoCode(true);
        }

        private void DoCode(bool bVisible)
        {
            if (bVisible)
            {
                //Do code in here
                MessageBox.Show("Verical scrollBar is now visible.");
            }
        }

its a simple one, but this is what you stated in the 1st post.
Mitja

Mitja Bonca 557 Nearly a Posting Maven

If you're just checking to see if the vertical scroll bar is enabled then you can tell the textbox to write multiple lines of text. Like:

void appLaunch()
{
richTextBox1.Text = "" + Environment.NewLine + "" + Environment.NewLine + "" + Environment.NewLine + "" + Environment.NewLine + "" + Environment.NewLine + "" + Environment.NewLine + "" + Environment.NewLine + "" + Environment.NewLine + "" + Environment.NewLine + "" + Environment.NewLine + "" + Environment.NewLine + "" + Environment.NewLine + "" + Environment.NewLine + "" + Environment.NewLine + "" + Environment.NewLine + "" + Environment.NewLine + "" + Environment.NewLine + "" + Environment.NewLine + "";
}

void timer3000ms()
{
richTextBox1.Text = "";
}

That will force around 15 lines of blank text into the text box, then with the timer, 3 seconds later it will erase the entire text box. Hope it helps. Wasn't too sure on what you're asking.

What is this example all about?

Mitja Bonca 557 Nearly a Posting Maven

Why would you delete whole dgv. You dont need to. If you want to delete the row, and the dgv is bound to a data source, you have to remove the row from this data source.
Then will surely work.

Mitja

Mitja Bonca 557 Nearly a Posting Maven

:) I thought it has to work.
bye
And close the thread (mark as answered).
Mitja

Mitja Bonca 557 Nearly a Posting Maven

and your solution is... ?

Mitja Bonca 557 Nearly a Posting Maven

try this:

int rowSelected = dataGridView1.CurrentCell.RowIndex;
Mitja Bonca 557 Nearly a Posting Maven

LOL... I got the code in my 1st attempt. No repairing it. Damn Im good :)

Here it is:

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

        private void button1_Click(object sender, EventArgs e)
        {
            Form2 f2 = new Form2(this);
            f2.Show();
        }

        public void SelectingText(string searchText, bool bSelectUp)
        {
           
            int position = textBox1.Text.IndexOf(searchText);
            if (position > 0)
            {
                if (bSelectUp)
                    textBox1.Select(position, (textBox1.Text.Length - position));
                else
                    textBox1.Select(0, (position + searchText.Length));
                textBox1.ScrollToCaret();
                textBox1.Focus();
            }
            else
                textBox1.DeselectAll();
        }
    }

//form2:
    public partial class Form2 : Form
    {
        Form1 f1;
        public Form2(Form1 _f1)
        {
            InitializeComponent();
            this.f1 = _f1;
            //select by defualt the up radio button (so one will always  be selected):
            radioButton1.Checked = true;
        }

        private void button1_Click(object sender, EventArgs e)
        {            
            string value = textBox1.Text;
            bool bSelectUp = (radioButton1.Checked) ? true : false;
            f1.SelectingText(value, bSelectUp);
        }
    }

Hope it helps,
Mitja

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

Ups.
So when will select UP:
will select the searching word and the rest of the letter to the right

When you will select DOWN:
will select the searching word and the rest of the letters to the left.

Am I right?

Mitja Bonca 557 Nearly a Posting Maven

Do you mean if you have more equal words, the search will go forward (from let to right) when up radioButton will be selected?

Mitja Bonca 557 Nearly a Posting Maven

What do you mean with radion buttons direstions?
YOu have only one "main textBox" so how will you be using these 2 radionbuttons? What would be the difference in selecting one or the other?

Mitja

Mitja Bonca 557 Nearly a Posting Maven

Lets say you were doing C# for 3 years. But now we have to ask you, what were you doing in these past 3 years? Have you learned every single day (for at least 2-3 hours for day), or did you only occasionally used any book(s) and Visual Studio for your practice, or there was something in between?
You see what I mean, its a big difference in those 3 examples. Someone can be almost an expert, when the other doesn`t even know what is (means) an Object in OOP, or how to use Lambda Expressions for an instance.

I am learning C# for around 2 years, and I can say every day, sometimes I`m infront of the book and pc for a lots of hours, sometimes maybe only for an hour (when I have a hard times with my work). But Iam doing a progress, even if its tuff. There is so much to learn, and every day comes something new.
In programming there is many areas that you can work on (like sql, win form, some specific coding - algoritms, or sometihng else), so its hard to learn all at ones. Best way is to go step by step, to learn sometihng and that you do that good. Its worthless to try to learn all, because on the end you will no nothing, or becuase there will be to many stuff at ones, or you will simply forget what you have been learing a couple …

Mitja Bonca 557 Nearly a Posting Maven

And do you have any clue what might cause the dictionary change? Because from the code, which looks clean, I cant find any reason for that.

Mitja Bonca 557 Nearly a Posting Maven

What exactly are you trying to do? Before pasting some code here, would be nice to do some basic explanation of what is your project aobut. So we can have a clue about, and then its a way easier for us to help you out.
Now I dont know what are you doing, and how can I / we help you. So some basic explanation would be welcome.

I hope you understand.
Mitja

Mitja Bonca 557 Nearly a Posting Maven

:) Indeed. Maybe we can find out some thing which even Microsoft doesn`t know, and it will be implemented in VS 4.5
:)

Mitja Bonca 557 Nearly a Posting Maven
string writetext = ListItemCom2.SelectedItems.ToString();

Is the error. You want to get an array and put it into a stirng. No go.

You needa loop, which will go through the listBox items, like:

FileStream fs2 = new FileStream(@"C:\Users\Fish\Desktop\fyp-coding\Combine.txt", FileMode.Append, FileAccess.Write, FileShare.Write);//create text file    
            StreamWriter sw2 = new StreamWriter(fs2, Encoding.Default);

            for (int i = 0; i < ListItemCom2.SelectedItems.Count; i++)
                sw2 = File.AppendText(@"C:\Users\Fish\Desktop\fyp-coding\Combine.txt");
            sw2.Flush();
            sw2.Close();

Hope it helps,
Mitja

Mitja Bonca 557 Nearly a Posting Maven

You cad do it like:

string answare = "j";
bool again = (answare == "j" || answare == "J") ? true : false;

about your issue: as ddanbe explained, (') is a type char, and I presume that variable answare is a type string ("). So these two will no go along. Or use one or the other.

This is a short version where you can choose between true of false.
Mitja

Mitja Bonca 557 Nearly a Posting Maven

Hi,
what kind of reports? Crystal Reports, or some else?
You can find some help about Crystal Reports here (which are by best by far - in my opinion):
http://www.codeproject.com/KB/cs/CreatingCrystalReports.aspx
http://www.codeproject.com/KB/database/MySQLCrystal.aspx
http://www.codeproject.com/KB/cs/Dynamic_Crystal_Report.aspx

Hope it helps,
Mitja

Mitja Bonca 557 Nearly a Posting Maven

Anytime. Just dont forget to close the thread and mark is as answered.
best regards,
Mitja

Mitja Bonca 557 Nearly a Posting Maven

Are you inserting into database, ot selecting from it? Regarding on your code (when using ExecuteNonQuery() method) you are inserting.

You have to change your format that will suit to the database` dateTime column format. You can do it like:

DateTime date = dateTimePicker1.Value.Date;
string sDate = date.ToString("dd-MM-yy", System.Globalization.CultureInfo.InvariantCulture);
DateTime dateInsert = Convert.ToDateTime(sDate); //use this dateInsert as parameter to insert into DB.

Mitja

Mitja Bonca 557 Nearly a Posting Maven

No problem. I am glad I can help.
If the issue has been salved, simply mark the thread as answered or vote the post as helpful.

bye, bye
Mitja

Mitja Bonca 557 Nearly a Posting Maven

This is surely again one of the school projects.
You have to create a win form from console.

Ok, I did your homework, and here`s the code:

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

        private void button1_Click(object sender, EventArgs e)
        {
            int intDrawersPerDesk = 0;
            int intAllDesks = 0;
            //1. checking if textBox of wood type is empty:
            string strWoodType = textBoxWoodType.Text;                       
            if (strWoodType != String.Empty)
            {
                //2. checking if its a number for number of desks
                if (int.TryParse(textBoxDrawsPerDesk.Text.Trim(), out intDrawersPerDesk))
                {
                    //3. checking if its a number for number of drawers
                    if (int.TryParse(textBoxAllDesks.Text.Trim(), out intAllDesks))
                    {
                        //4. calculations, and checking of any of the numbers are zero
                        int intAllDrawers = NumberOfDrawers(intDrawersPerDesk, intAllDesks);                        
                        if (intAllDrawers > 0)
                        {
                            //5. checking exact wood type
                            string strShortWoodType = WoodType(strWoodType);
                            if (strShortWoodType != "error")
                            {
                                float fTotal = CalculateTotalCost(strWoodType, intAllDrawers);
                                MessageBox.Show("The total code is " + fTotal + ".");
                            }
                            else
                                MessageBox.Show("Please enter the correct wood type (mahogany, oak or pine).");
                        }
                        else
                            MessageBox.Show("Sum of all drawers is zero. Please higher the number of desk or drawers.");
                    }
                }
            }
            else
                MessageBox.Show("Please enter the correct wood type.");
        }

        private int NumberOfDrawers(int intDrawersPerDesk, int intAllDesks)
        {
            return intDrawersPerDesk * intAllDesks;
        }

        public string WoodType(string strTreeType)
        {          
            switch (strTreeType)
            {
                case "mahogany":
                    {
                        strTreeType = "m";
                        break;
                    }
                case "oak":
                    {
                        strTreeType = "o";
                        break;
                    }
                case "pine":
                    {
                        strTreeType = "p";
                        break;
                    }
                default:
                    {
                        strTreeType = "error";
                        break;
                    }
            }
            return strTreeType;
        }

        private float …
Mitja Bonca 557 Nearly a Posting Maven

DataSource is a property of some controls (like DataGridView) which is used for binding data to these Controls.

The best would be to look an example:

public partial class Form1 : Form
    {
        DataGridView dgv;
        DataTable table;
        BindingSource bs;
        public Form1()
        {
            InitializeComponent();
            
            dgv = new DataGridView();
            dgv.Location = new Point(20, 20);

            //this will always create a new row in the end of dgv:
            //when user will do insertion into new row of dgv, 
            //data will be automatically transfered to dataTable as well!
            dgv.AllowUserToAddRows = true;
            this.Controls.Add(dgv);
            CreatingDataSource();
        }

        private void CreatingDataSource()
        {
            table = new DataTable("myTable");
            table.Columns.Add("Id", typeof(int));
            table.Columns.Add("Name", typeof(string));
            //get some example data:
            table = GetData(table);
            //bind table to binding source:
            bs = new BindingSource(table, null);
            //bind binding source to dgv:
            dgv.DataSource = bs;
        }

        private DataTable GetData(DataTable table)
        {
            //my example data (I will add 2 rows):
            DataRow dr;
            for (int i = 1; i < 3; i++)
            {
                dr = table.NewRow();
                dr["Id"] = i;
                dr["Name"] = "name " + i;
                table.Rows.Add(dr);
            }
            return table;
        }
    }

Hope it helps,
Mitja

ddanbe commented: Good explanation! +9
Mitja Bonca 557 Nearly a Posting Maven

No, you have to put the instance of the Random on the class level, then you will not have problems with getting random number every where (on load event, or on some button click event, or in some method):

//form1 class:
Random r = new Random();
public Form1()
{
    //constructor of form1
    IntializeComponent();
    int a = r.Next(100,201);  //for example!
    MessageBox.Show(a.ToString());
}

private void  button1_Click()
{
   int myNumber = r.Next(0,101); //for example!
   MessageBox.Show(myNumber.ToString());
}

Hope it helps,
Mitja

Mitja Bonca 557 Nearly a Posting Maven

When you remove an item (or add one) to a list it messes up the Selected values. You can't rely on them being valid anymore. What you need to do is copy the selected values somewhere else then use that new copy to remove the items.

Can you show me an example please?

Mitja Bonca 557 Nearly a Posting Maven

Try using SelecredIndices collection:

public Form1()
        {
            InitializeComponent();
            
            //my test population:
            char[] array = "abcdef".ToCharArray();
            for (int i = 0; i < array.Length; i++)
                listBox1.Items.Add(array[i]);
            listBox1.SelectionMode = SelectionMode.MultiExtended;
        }

        private void button1_Click(object sender, EventArgs e)
        {
            while (listBox1.SelectedIndices.Count > 0)
                listBox1.Items.RemoveAt(listBox1.SelectedIndices[0]);
        }
Mitja Bonca 557 Nearly a Posting Maven

Try this:

string a = "12.34";
decimal b = Convert.ToDecimal(a, System.Globalization.CultureInfo.InvariantCulture);
Mitja Bonca 557 Nearly a Posting Maven

You can see from the exception, that your conversation is not ok.
Try to do:

DateTime dateDate = Convert.ToDateTime(reader["dtFrom"]); //column "dtFrom" has to be type of DateTime!

but as it seems from your excetion, your column "dtFrom" is a type of varchar (so string, and no DateTime).
So you can do:

string strDate = (string)reader["dtFrom"];
//if you want some further "date" changing (from whole date-time value to only date for example) you can do:
DateTime dateDate = Convert.ToDateTime(strDate);
strDate = String.Format("{0:MM.dd.yyyy}", dateDate);
//or:
strDate = dateDate.ToShortDateString();

The point is that you have wrong type of columns in the dataBase. If you have dates, times, the type has to be a "DateTime", and notihng else (its very desired). And if we skip this issue, and go back to yours here, conversations arent good enought, and mostly becuase of wrong column types.

Hope this explains your problem - but my code above shoud salve them all anyway - regarldess on wring column types.

Mitja

Mitja Bonca 557 Nearly a Posting Maven

:) damn. I forget about it every time.
I will try to remember to use from now on in cases like this.
Thx momerath.

Mitja

Mitja Bonca 557 Nearly a Posting Maven

Sure, you cannot show an array in a messageBox (its like putting a string array into stirng - cant do).
You have to get all values from an array into a string, then show it in messageBox:

string[] myname = new string[2];
            myname[0] = "Shahid";
            myname[1] = "Hussain";
            string items = null;
            for (int i = 0; i < myname.Length; i++)
                items += myname[i] + Environment.NewLine;
            MessageBox.Show("This is the list:\n" + items);

Hope it helps,
Mitja

yousafc# commented: He is best Developer +0
Mitja Bonca 557 Nearly a Posting Maven

So the code does not go through that for loop. That means the "lenght" is 0.

Mitja Bonca 557 Nearly a Posting Maven

Sure you cannot. This will not do:

for (int i = 0; i == length; i++)
 {
      lblWord.Text = lblWord.Text + "_";
 }

You have to do the loop which will go through it:

for (int i = 0; i < length; i++)
 {
      lblWord.Text += "_";  //this will do it too :)
 }

Mitja

Mitja Bonca 557 Nearly a Posting Maven

Something lke that?

private void method()
        {
            const int value = 5;
            string tag = "_";
            string item = "";
            for (int i = 0; i < value; i++)
                item += tag;
            MessageBox.Show("You have chosen " + value.ToString() + " underscores.\nThe result is: \"" + item + "\"");
        }

Mitja

Mitja Bonca 557 Nearly a Posting Maven

You can hind Form1, and open form2.

//on button click:
Form2 f2 = new Form2();
this.Hide();
f2.Show();

If you will close or dispose Form1, the whole application will close, thats because in Program class you called "Application.Run(new Form1());" so this holds up everything.

Mitja Bonca 557 Nearly a Posting Maven

Look at this code, it removes the duplications:

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

        private void CreatingDS()
        {
            ds = new DataSet();
            DataTable table = new DataTable("MyTable");
            table.Columns.Add("id", typeof(int));
            table.Columns.Add("name", typeof(string));

            string[] names = { "A", "B", "C", "A", "B" };
            DataRow dr;
            for (int i = 0; i < names.Length; i++)
            {
                dr = table.NewRow();
                dr["id"] = i + 1;
                dr["name"] = names[i];
                table.Rows.Add(dr);
            }
            ds.Tables.Add(table);
            table = RemoveDuplicateRows(table, "name");

            comboBox1.DataSource = ds.Tables["MyTable"];
            comboBox1.DisplayMember = "name";
            comboBox1.ValueMember = "id";
        }

        public DataTable RemoveDuplicateRows(DataTable dTable, string colName)
        {
            Hashtable hTable = new Hashtable();
            ArrayList duplicateList = new ArrayList();

            foreach (DataRow drow in dTable.Rows)
            {
                if (hTable.Contains(drow[colName]))
                    duplicateList.Add(drow);
                else
                    hTable.Add(drow[colName], string.Empty);
            }

            foreach (DataRow dRow in duplicateList)
                dTable.Rows.Remove(dRow);

            return dTable;
        }
    }

hope it helps,
Mitja

AngelicOne commented: thanks for combobox removal of dups! +1
Mitja Bonca 557 Nearly a Posting Maven

Hi, would you mind describling your issue a bit better? I really dont understand what would you like to achive. But somehow I would say choosing Buttons for this task isnt the right option. Have you thought of what Momerath has proposed to you?
If you think differently, please go ahead and explain a bit mor precise.
Mitja

Mitja Bonca 557 Nearly a Posting Maven

Did you check the whole code? The code works, I guess you didnt see the "Form2 f2;" variables on top of the constructor of form1.

public partial class Form1 : Form
    {
        [B]Form2 f2;[/B]
        public Form1()
        {
            InitializeComponent();
        }
 
        //open form2 someplace else!!
        //before calling event bellow!
        private void button2_Click(object sender, EventArgs e)
        {
            f2.UpdateFormColor();
        }
    }

The same goes if you have more forms open. Get all opened forms and create that same method on other forms, and call them:

public partial class Form1 : Form
    {
        [B]Form2 f2;
        Form3 f3;[/B]//you need to have this instances of the forms visible to all class so they can be used!
        public Form1()
        {
            InitializeComponent();           
        }

        private void SetColorToForms()
        {
            foreach (Form form in Application.OpenForms)
            {
                if (form.Name = "Form2")
                    f2.UpdateFormColor();
                else if(form.Name =="Form3")
                    f3.UpdateFormColor();
            }
        }
    }
johnt68 commented: Extremely helpful ... and patient - thank you. +1
Mitja Bonca 557 Nearly a Posting Maven

If your form is already opened:

//form1:
    public partial class Form1 : Form
    {
        Form2 f2;
        public Form1()
        {
            InitializeComponent();
        }

        //open form2 someplace else!!
        //before calling event bellow!
        private void button2_Click(object sender, EventArgs e)
        {
            f2.UpdateFormColor();
        }
    }

//form2:
    public partial class Form2 : Form
    {
        public Form2()
        {
            InitializeComponent();
        }

        public void UpdateFormColor()
        {
            this.BackColor = Color.YellowGreen;
        }
    }

Hope it helps,
Mitja

ddanbe commented: Constant effort. +8
Mitja Bonca 557 Nearly a Posting Maven

Is this other forms already opened?

Mitja Bonca 557 Nearly a Posting Maven

You need to use delegate, look at this my example:

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 Feb27Exercise1
{
    public partial class Form1 : Form
    {
        System.Threading.Thread thread;
        delegate void TextBoxDelegate(string message);

        public Form1()
        {
            InitializeComponent();
        }


        private void button1_Click(object sender, EventArgs e)
        {
            CreatingNewThread();
            while (thread.IsAlive)
                Application.DoEvents(); //waiting for termination!
            thread.Join();  //termninate thread!
        }

        private void CreatingNewThread()
        {
            int myValue = 40; //some value to pass as parameter to the other Thread
            OtherClass other = new OtherClass(this); //passing param to constructor 
            thread = new System.Threading.Thread(new System.Threading.ParameterizedThreadStart(other.SomethingToDo));
            thread.Start(myValue);
        }

        public void UpdatingTextBox(string msg)
        {
            if (this.textBox1.InvokeRequired)
                this.textBox1.Invoke(new TextBoxDelegate(UpdatingTextBox), new object[] { msg });
            else
                this.textBox1.Text = msg;
        }
    }

    public class OtherClass
    {
        Form1 form1;
        public OtherClass(Form1 _form1)
        {
            this.form1 = _form1;
        }

        public void SomethingToDo(object obj)
        {
            //I will create an example loop which, 
            //from which I will pass the value to textBox on form1 class:
            int myValue = Convert.ToInt32(obj);
            for (int i = 0; i < myValue; i++)
            {
                form1.UpdatingTextBox(i.ToString());
                //wait for a bit:
                System.Threading.Thread.Sleep(200);
            }
        }
    }
}

If it does not help, let me know, and dont forget to past some of your code in here -so that I can see whats it your problem, ok?

Mitja

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

Hi,
your code looks pretty strange, especially the using(xxx) row, but I dont know what those variables mean, so hard to tell...
Lets make it a bit different:

private void DeletingDataBase()
        {
            using (SqlConnection sqlConn = new SqlConnection("ConnectionString"))
            {
                using (SqlCommand cmd = new SqlCommand())
                {
                    string sqlQuery = "SELECT, INSERT, UPDATE, DELETE";
                    cmd.Connection = sqlConn;
                    cmd.CommandText = sqlQuery;
                    cmd.Connection.Open();
                    try
                    {                        
                        cmd.ExecuteNonQuery();
                    }
                    catch { /*catch an error in here*/ }
                    finally
                    {
                        cmd.Connection.Close();
                    }
                }
            }
        }

Back to your question. Answer is: No.
When you use a keyword "using" the newly created instance in there, closes it self when leaving the using brackets.
This is the same of every instance created (i.e: SqlConnection, StreamReader ...).
But if some einstance needs an open connection, you have to open it (manully) in the code (i.e: sqlConn.Open();).

using(SqlConnection sqlConn = new SqlConnection("string"))
{
    //open the connect (if needed)!
}//here the connection closes it self!

Hope it helps,
Mitja