Mitja Bonca 557 Nearly a Posting Maven

You have to use DataBinding. Get the data you want to show in textBoxes in the dataTable, then set data binding for each textBox and use "CurrencyManager".

Here is a great example, its all there.
Take your time to study all whats there on this website.

cya

Mitja Bonca 557 Nearly a Posting Maven

I would say this is happening in the last row, where no data in presented.
Try to do some checking for a "NewRow", this is the property which checks if the row is a new one (the last one actually):

DataTable table = new DataTable(); // get the members (new ones)
            //now lets check if the member from table is already in the DGV:
            foreach (DataGridViewRow row in dataGridView1.Rows)
            {
                if (!row.IsNewRow) //checking for a new row
                {
                    string memeberDGV = dataGridView1[0, row.Index].Value.ToString();
                    foreach (DataRow dr in table.Rows)
                    {
                        string memberDT = dr[0].ToString();
                        if (memeberDGV == memberDT)
                        {
                            //member already exists in dgv!
                        }
                    }
                }
            }
Mitja Bonca 557 Nearly a Posting Maven

Hmm, Tellalca? What an answer is that?? If you want to comment threads like that, you better do NOT write at all. Otherwise you will be penelized, ok?
Sorry for inconveniances.

Ok, back to the thread`s topic, you can bind data from dataTable, which gets filled from database like this:

DataTable table = new DataTable();
using(SqlConnection sqlConn = new SqlConnection("connString")) //use your conn. string here
{
   using(SqlDataAdapter da = new SqlDataAdapter(@"SELECT Id, Name FROM Person", sqlConn))
       da.Fill(table);
}
comboBox1.DataSource = new BindingSource(table, null);
comboBox1.DisplayMember = "Name"; //colum you want to show in comboBox
comboBox1.ValueMember = "Id"; //column you want to use in the background (not necessary)!

This is about it. Oh yee, rename the sql select query, and use your own names (table and field names) from database.

Hope it helps,

Mitja Bonca 557 Nearly a Posting Maven

The code looks fine, the only problem is, that the ID should not be let to be insterted by the user (from textBox). It has to be created some how automatically, so starting from 1,2,3, and so on (each new id is +1, incrementally).
I would suggest you to get the last inserted id, and increment it, so you get a new one. Then insert other data as well.

Mitja Bonca 557 Nearly a Posting Maven

Just make sure the able name of the DataTable objects (the variable name, like I used "table") are different. With other words, table names must be different one to each other. Then you can have 100 of them at ones.

Mitja Bonca 557 Nearly a Posting Maven

If you want to get data from one table of the database to a dataTable, and populate a comboBox with the data from one of the columns of the dataTable, then you can do:

DataTable table = new DataTable(); // get the members (new ones)           
            using (SqlConnection sqlConn = new SqlConnection("connString"))
            {
                using (SqlDataAdapter da = new SqlDataAdapter(@"SELECT * FROM MyTable", sqlConn))
                    da.Fill(table);
            }
            if (table.Rows.Count > 0)
            {
                comboBox1.DataSource = table;
                comboBox1.DisplayMember = "Column1"; //SelectedItem, write the name of the column you want to show in comboBox, like Name
                comboBox1.ValueMember = "Column2";//this will be a SelectedValue, like ID
            }
Mitja Bonca 557 Nearly a Posting Maven

If its only this, then yoz can do:

// firstname, lastname, membership, accountid, date
            DataTable table = new DataTable(); // get the members (new ones)
            //now lets check if the member from table is already in the DGV:
            foreach (DataGridViewRow row in dataGridView1.Rows)
            {
                string memeberDGV = dataGridView1[0, row.Index].Value.ToString();
                foreach (DataRow dr in table.Rows)
                {
                    string memberDT = dr[0].ToString();
                    if (memeberDGV == memberDT)
                    {
                        //member already exists in dgv!
                    }
                }
            }
Mitja Bonca 557 Nearly a Posting Maven

For the password, you should use ExecuteDataReader()

ExecuteSclalar is appropriate here too, because it returns a single value.
But its not appropriate to return the password, because you dont actually use it any where, password should only (meant) be to check if the user is the right one, or not.
But I dont exactly know why you use the password, so do as you like.

Mitja Bonca 557 Nearly a Posting Maven

Have you managed to salve this issue? If not, please provide us more details about this issue.
thx in advance.
bye

Mitja Bonca 557 Nearly a Posting Maven

This is a not a problem code.
I actually really dont understand what exactly are you trying to do here.
Ok, you this SELECT sql query, which gets Users data (fist and last name, and id).
You populated DGV with these data.
Then what?

Please dont just from one issue to another.
Continue from where I stopped.

Mitja Bonca 557 Nearly a Posting Maven

1. You have a WPF project and It already has a window. You are able to run this application.

2. Now you right click on the project and Add new Window. You name it MyNewWindow.xaml

3. You would now notice MyNewWindow.xaml and MyNewWindow.xaml.cs added to your project. (the class name for the window would be MyNewWindow which is in the .xaml.cs file and it derives from Window; also a partial class)

4. Open the XAML file for the MyNewWindow (MyNewWindow.xaml) and add your controls. Treat it like any other window and write code.

5. Now in your main window (the first one) you add a Button which when clicked should show the newly created window.

For that inside the Click handler, ....

var newWindow = new MyNewWindow();
newWindow.Show();


This would create a new instance of the MyNewWindow and shows it to the user. It would appear just as you designed in your XAML.

If this is an issue, let me know so that I will upload a sample application and link you with it.

Mitja Bonca 557 Nearly a Posting Maven

Here is the code you want. It check all the possibilities.
Let me know what you think:

Private labelClicked As Integer
Public Sub New()
	InitializeComponent()
	Dim labels As Label() = {label1, label2, label3, label4, label5, label6, _
		label7, label8}
	For i As Integer = 0 To labels.Length - 1
		labels(i).Tag = i
		labels(i).Click += New EventHandler(AddressOf Labels_Click)
	Next
End Sub

Private Sub Labels_Click(sender As Object, e As EventArgs)
	Dim l As Label = TryCast(sender, Label)
	Dim currentTag As Integer = CInt(l.Tag)
	If labelClicked < 8 Then
		If labelClicked <> currentTag Then
			If labelClicked < currentTag Then
				MessageBox.Show([String].Format("Please select label{0} before label{1}.", (labelClicked + 1), (currentTag + 1)))
			Else
				MessageBox.Show([String].Format("Label{0} has already been selected.", (currentTag + 1)))
			End If
		Else
			labelClicked += 1
			'color selected label for example:
			l.ForeColor = Color.Red
			If labelClicked.Equals(8) Then
				MessageBox.Show("All labels are selected now.")
			End If
		End If
	Else
		MessageBox.Show("You have already selected all the labels.")
	End If
End Sub
Mitja Bonca 557 Nearly a Posting Maven

Timer would sulrey be a better option then using Thread.Sleep() method.
As nick already explained, you have to create a new instance of a Timer (Windows.Forms.Timer class!), and in the for load event (or in constructor), subscribe to a Tick event, which will be fired (after a time declated in the Interval property).
As said, set Interval property to 3000 (this is 3 sec), and Start it (use start method). After 3 seconds Tick event will be rised. There put your code inside, or call another method (which is a better option), and Stop your timer, so it will no rise this same event again (if you dont need to of course).
thats it.

Mitja Bonca 557 Nearly a Posting Maven

you fould what?
Please paste the solution here (but it must be same as mine or Teme64`s, regarding on your question in 1st post)?!

Mitja Bonca 557 Nearly a Posting Maven

What I meant is (in my upper question) do you use any textBox or any other control to find the member?
I dont know how you are looking for, what is your criteria.
I need more data...

abd btw, you said you have data in database. This application is actually for searching and updating user`s data, am I right?

Mitja Bonca 557 Nearly a Posting Maven

Hi,
What do you mean? How you intend to find it?

Mitja Bonca 557 Nearly a Posting Maven

if you set the variable as type of string, it cannot change, because string is immutable (that means it cannot be changed ones its been created).

For sure somewhere in your code you create a new string for this variable. Double Check your code.

Mitja Bonca 557 Nearly a Posting Maven

or:

ara.Text = "\\";
Mitja Bonca 557 Nearly a Posting Maven

If you got the answer, please close the thread by marking as salved (answered).
thx in advance ;)

Mitja Bonca 557 Nearly a Posting Maven

hehe, no problem mate, I really like to help.
Cya around.

Mitja Bonca 557 Nearly a Posting Maven

You have to use UPDATE sql statement, not INSERT!!
like:
"UPDATE MyTableName SET @field2, @field3, @filed4 WHERE FieldName1 = @filed1"

Behind the SET keyword specify the field names (columns) you want to update. No need all, just those you want to update. And you must use a WHERE clause, so the code knows which row to update.
As simple as that.

Mitja Bonca 557 Nearly a Posting Maven

You could you delegates and event. This is the simpliest way to do it.
You need any help?

Mitja Bonca 557 Nearly a Posting Maven

You are here showing only how you insert data from dgv A into a database.
Do you then populate dgv B from dataBase, of from dgv A?

Mitja Bonca 557 Nearly a Posting Maven

Hmm, then we have a problem here.
The code is meant to work in Win form.
About the generic list, it uses a "System.Collections.Generic" namespace (reference).

Put this code into a win form, and dont just copy/paste it, but you have to add event for controls, like (buttonSource_Click, ...), and then paste the code from here to your event.

ddanbe commented: Helpfull! +14
Mitja Bonca 557 Nearly a Posting Maven

LOL - your form look EXACTLY the same as mine :) , but I mean EXACTLY the same. Even buttons have three dots inside. Unbelivable.

So I can give you the code:

List<FileInfo> listOfFiles;
        public Form1()
        {
            InitializeComponent();
            listBox1.SelectionMode = SelectionMode.MultiSimple;
        }

        private void buttonSource_Click(object sender, EventArgs e)
        {
            listOfFiles = new List<FileInfo>();
            FolderBrowserDialog openFileDialog1 = new FolderBrowserDialog();
            openFileDialog1.SelectedPath = @"C:\";
            if (openFileDialog1.ShowDialog() == DialogResult.OK)
            {
                string dirPath = openFileDialog1.SelectedPath;
                //set the path to the textBOx:
                textBox1.Text = dirPath;
                //filter for all images:
                string[] filters = { "*.jpg", "*.bmp", "*.png" };

                //get all the imeges to a list<T>:
                foreach (string filter in filters)
                {
                    FileInfo[] files = new DirectoryInfo(dirPath).GetFiles(filter);
                    foreach (FileInfo file in files)
                    {
                        listOfFiles.Add(file);
                    }
                }
            }
            //adding file names to listBox:
            foreach (FileInfo file in listOfFiles)
                listBox1.Items.Add(Path.GetFileNameWithoutExtension(file.FullName));
        }

        private void buttonDestination_Click(object sender, EventArgs e)
        {
            FolderBrowserDialog openFileDialog1 = new FolderBrowserDialog();
            openFileDialog1.SelectedPath = @"C:\";
            if (openFileDialog1.ShowDialog() == DialogResult.OK)
            {
                string dirPath = openFileDialog1.SelectedPath;
                //set the path to the textBOx:
                textBox2.Text = dirPath;               
            }
        }

        private void buttonProcess_Click(object sender, EventArgs e)
        {
            //I will only show how to work with selected files from listBox:
            //my example will only count selected files:
            int counter = 0;

            for (int i = 0; i < listBox1.SelectedItems.Count; i++)
            {
                string name = listBox1.SelectedItems[i].ToString();
                //find the file in generic list:
                foreach (FileInfo file in listOfFiles)
                {
                    if (name == Path.GetFileNameWithoutExtension(file.Name))
                    {
                        counter++;
                        //you use the destinaton path here to do something (or you will copy or what ever)!!
                    }
                }
            }

            MessageBox.Show("You …
Mitja Bonca 557 Nearly a Posting Maven

Hi, Im doing some code for you.
I have salved the 1st point (I am using "FolderBrowserDialog" object - which is only meant to choose a folder, so no files showed; thisis best for you since you want to get only spcific files.

Lets go to 2. point:
Why would you have then two textBoxes. Didnt you say in 1st point that you have a button to choose the directory? Why then having a directory path in the source textBox? The source path you will choose with that button.
We can do this way:
- two textBoxes
- two buttons on the end of those textBoxes
- on clicking on each button, FolderBrowserDialog will open and you will choose the destinations (for source and for destination path).


4. point is simple you will work only with "SelectedItems".

What do you think?

Mitja Bonca 557 Nearly a Posting Maven

You are welcome mate.

Mitja Bonca 557 Nearly a Posting Maven

I guess soem of your converting to integer from stirng throuwn an exception.
Please double check if your textBoxes which MUST have integers only, do really have them. My guess is that is one of them textboxes there is not only a number inside (a number without any decimal places -thats an integer).

What you can do, to make sure this kind of exception will not happen again, is to use some int checking (I will only show you two examples, for the rest do it by your own):

string payNoSp = PayNoSp.Text;
string addsp = Addsp.Text;
if(int.TryParse(payNoSp, out paynosp) && int.TryParse(addsp, out spAdd))
{
     if (stype == "Baptismal")
     {
         stypeid += "1";
         payfp += "200";
     }
     //and rest of the code here bellow...
}
else
     MessageBox.Show("Please insert only numbers for appropaite fields.");
Mitja Bonca 557 Nearly a Posting Maven

Hi,
tb_order.order_quantity or tb_use.use_quantity are updated, you can then create another command to update item_stock, like:

SqlConnection sqlConn = new SqlConnection("connString");
SqlCommand cmd = new SqlComand();
cmd.ComamndText = @"UPDATE tb_order SET order_quantity = @quantity WHERE (create a condition here"; //no parentheses!
cmd.Connection = sqlConn;
sqlConn.Open();
cmd.ExecuteNonQuery() //do 1st update
//then:
cmd = new SqlComand();
cmd.CommandText = @"UPDATE tb_inventory SET item_stock WHERE (create a conditon here)"; //no parentheses
cmd.ExecuteNonQuery(); //do 2nd update
//close IDisposable objects:
cmd.Dispose();
sqlConn.Dispose();

But you can still use some stored procedure, where you can define both update in one procedure. But i would do it this way, like I showed.

Mitja Bonca 557 Nearly a Posting Maven

You want to send actually from a hotmail (like in my example from gmail)?
I dont actually know the data needed for hotmail, you have to get it by your own (try checking on your hotmail account for Host, and Port properties).

Mitja Bonca 557 Nearly a Posting Maven

Check this example code, it works well:

System.Net.Mail.MailMessage message = new System.Net.Mail.MailMessage();
message.To.Add("emails to send to(multiple are seperated by comma");
message.Subject = "subject";
message.From = new System.Net.Mail.MailAddress("Mail From -you email");
message.Body = "body text"
System.Net.Mail.SmtpClient smtp = new System.Net.Mail.SmtpClient();
smtp.Host = "smtp.gmail.com";
smtp.Port = 587;
smtp.EnableSsl = true;
smtp.Credentials = new System.Net.NetworkCredential("userName, "password"); //write username and pswd if your email has it
smtp.Send(message);
Mitja Bonca 557 Nearly a Posting Maven

try this:

Dim exampe As String = "this is text."
Dim bigLetter As String = System.Globalization.CultureInfo.CurrentCulture.TextInfo.ToTitleCase(exampe)
Mitja Bonca 557 Nearly a Posting Maven

I have a form with multiple combo boxes and text boxes making an invoice.. I have the combo boxes linked to my database and I want each selection to fill a different textbox. The comboboxes fill on form load... How can I fill the textbox with the selected index from the combobox? Any help will do. I am using Visual Studio 2010 in .net not C#

I suggest you to fill DataTables. Each dataTable for each comboBox (so you will have data seperated). Then you use DataBinding, which will be based on each comboBox selection.

Mitja Bonca 557 Nearly a Posting Maven

Then you can try to do:

Console.Write("Enter command =>");
String command = Console.ReadLine();
int i = 0;
if (command.Length ==1) 
    Int32.TryParse(command.Substring(0,1), out i); //1 character input
else if(command.Lenght == 2)
    Int32.TryParse(command.Substring(1,1), out i); //2 characters input
//or more if you need

In case if you only want to get last character (if there is only character, it will take 1), then you can do:

Console.Write("Enter command =>");
string command = Console.ReadLine();
int i = int.Parse(command.Substring(command.Lenght -1, 1)); //this will always return last character - and oyu make sure its an integer!!
Mitja Bonca 557 Nearly a Posting Maven

Substring is a method that has two parametes:
1. Starting index
2. Numbers of characters

So when you call Substring(1, 1) -> that means you are taking 2nd character only (starting index is 1, and you take 1 character).

And because you are parsing to integer - it MUST be an integer. If there anythng else then a number it will give an error.

So a better handling of this kind of an exception, would be to check which character this is, and then decide what to do, like:

Console.Write("Enter command =>");
string command = Console.ReadLine();              
int i = 0;
if(int.TryParse(command.Substring(1, 1), out i)) //do the checking is characte is really a number 
{                
     if(command == "m") menu(); 
     else if (command == "p") PrintPuzzle(); 
     else if (command.Substring(0, 1) == "n") shuffle(i);
     else if (command.Substring(0, 1) == "r" && i<= numCols) moveRowRight(i);
     else if (command.Substring(0, 1) == "c" && i <= numRows) moveColDown(i);
     else if (command.Substring(0, 1) == "x")
           System.Environment.Exit(0);
     else     
           Console.WriteLine("Invalid command entered.");
}
else
       Console.WriteLine("Character is not a number - cannot continue.");
Mitja Bonca 557 Nearly a Posting Maven

Try this code I am using:

static class Program
{
   [STAThread]
   static void Main()
   {   
       using (Login login = new Login())
       {
            login.StartPosition = FormStartPosition.CenterScreen;
            if (login.ShowDialog() == DialogResult.OK)
            {      
                  Application.Run(new Form1(login.strUserName)); //passing the userName to the constructor of form1 (from Login form - global variable)!
            }
       }
    }
}

//form1:
public partial class Form1 : Form
{  
     string userName; 
     public Form1(string _strUser)
     {   
           InitializeComponent();
           userName = _strUser; //a local variable of a form1 class has hold user`s name (userName - which u can call it from within the form1 class!
     }
}

public partial class Login : Form
{
       public string UserName { get; private set; } 
       public Login()
       {
              InitializeComponent();
       }

       private void btn_Login_Click(object sender, EventArgs e)
       {
             string userName = textBox1.Text.Trim();
             string pswd = textBox2.Text.Trim();
             bool bLoginOk = CheckUser(userName, pswd);
             if (bLoginOK)
             {
                  this.DialogResult = DialogResult.OK;
                  this.UserName = userName; //setting global variable (a property) so it can get the name out of it later (from program.cs)
                  //code will close login form, and go back to program.cs ...
             }
             else
            {
                 //you can show here a messageBox that userName and password do not match if you like!
                 //AND the login form still stays open!!
            }
      }
   
  
      private bool CheckUser(string name, string pswd)
      {
            bool bChecking = false;

            //do the login checking, if username and password match, return true, else false

            //if username and password match:
            bChecking = true;

            return bChecking;
      }     
}
Mitja Bonca 557 Nearly a Posting Maven

Tell us your problem, and paste the (necessary) code!! (not all of it :) ) that there is an issue in here.
And we`ll try to help you out.

Mitja Bonca 557 Nearly a Posting Maven

Yes, but you have to use a referece of TimeSpan object, like:

textBox5.Text = ts.Hours.ToString();
//and so on...
Mitja Bonca 557 Nearly a Posting Maven

So you would like to learn multidimensional arrays?

Try to use for loops with them:

int[,] myInts = new int[2,3] { 1, 2, 3 }, { 4, 5, 6 } };
for(int i = 0; i < myInts.GetLenght(1); i++)
{
    for(int j = 0; j < myInts.GetLenght(0); j++)
    {
         Console.WriteLine("{0}", myInts[j, i]);
    }
}
Console.ReadLine();
Mitja Bonca 557 Nearly a Posting Maven

Ups, i did a mistake on last line of code, to get total minutes you have to do:

int minutes = ts.TotalMinutes; // here you get the difference between t1 and t2 in minutes
//the same you can do for other values of time (millinsends, hours,...)

About your last post:
You can NOT parse TimeSpan to Stirng!!!

Tell me, what value you want to get out, seconds, minutes, hours, what?

Look this example of mine here:

int minutes = ts.TotalMinutes;
//to get a string you only do:
string strTotalMinutes = ts.TotalMinutes.ToString();
Mitja Bonca 557 Nearly a Posting Maven

What do you mean to get the difference between two dates in the integer type?
the number in minutes, seconds, hours, or something else?

To get the difference you have to use TimeSpan class, which has all the time values (seconds, minutes, hours, milliseconds,..).
You can do it:

DateTime t1 = dateTimePicker1.Value;
DateTime t2 = dateTimePicker2.Value;
//now lets assume that t1 is older date:
TimeSpan ts = t2.Subtract(t1);
int minutes = ts.Minutes; // here you get the difference between t1 and t2 in minutes
//the same you can do for other values of time (millinsends, hours,...)

About your 2nd question, i didnt really understand it (that you cant select it the front end) - What is that suppose to mean?
Look how I did in the example, and try to do it the same way.

Mitja Bonca 557 Nearly a Posting Maven

Check here for some ideas how to do the server-client projects.

Mitja Bonca 557 Nearly a Posting Maven

As Memorath said, DateTime cannot be changed. But you can parse it to string, and change the string to your own "datetime" format (but remember, this is not going to be a real DateTime value anylonger).

try this:

DateTime date = DateTime.Now.Date; 
string strDate = date.ToString("yyyy-MM-dd 00:00:00");
Mitja Bonca 557 Nearly a Posting Maven

how do I code the query for getting data from table where datadate = valueofdatepicker or < 15 days
something like
SELECT * FROM EMPLOYEE WHERE Hireddate BETWEEN ( @date and @date-15days) <---how do I subtract the 15 days?

If you mean to get some data based on two conditions, two dates actually (between those two dates), then you can do it:

string query = @SELECT * FROM EMPLOYEE WHERE Hireddate >= @date1 and AND Hiredate <= @date1)
SqlConnection sqlConn = new SqlConnection("connString");
SqlCommand cmd = new  SqlComamnd(query, sqlConn);
cmd.Parameters.Add("@date1", SqlDbType.DateTime).Value = dateTimePicker1.Value;
cmd.Parameters.Add("@date1", SqlDbType.DateTime).Value = dateTimePicker1.Value.AddDays(15); //if you want to add 15 days on dtp selection!
Mitja Bonca 557 Nearly a Posting Maven

Change sql query to:

insertDatetime = @"UPDATE WaynokaLogger SET Date = @Date WHERE AccountID = '" + newString + "'";

or use parametreized query:

insertDatetime = "UPDATE WaynokaLogger SET Date = @Date WHERE AccountID = @id";
da.UpdateCommand = new SqlCommand(insertDatetime, cs);
da.UpdateCommand.Parameters.AddWithValue("@Date", SqlDbType.DateTime).Value = DateTime.Now;
da.UpdateCommand.Parameters.AddWithValue("@id", SqlDbType.Int).Value = newString;
Mitja Bonca 557 Nearly a Posting Maven

You dont need to use ID as Where clause, you can use a name, or lastname, or both or them, or some other field.
But the problem comes, when there are duplicates of names (or lastnames, or whatever field). Thats why we use ID column. Id is (must be) unique, and cannot be duplicated.
That why its strongly recommended to use for a where clause an id field.

But if you want to do an update and use a where clause, you have to know this particular id. You have to get it some how.
Are you able to get it?
If so, there is no problem, if not, you have to think of some way to get it.
Thats why its best to have to dataTable, where are all the fields inside (with all the rows (all the data)), so you have in one row: an id, name, lastname, and other columns.
So when you want to update some date, you get this particular row out, and now you are sure that an Id belongs only to the name and lastname from this row.
And this way you can simply do an update.

You know what I mean?
Read carefully, and try to do some examples, and let me know.

Mitja Bonca 557 Nearly a Posting Maven

Do you use any DataSource? You better be using it - like DataTable. And when you will do changes in datagridview, all changes will reflct in dataTable as well.

Mitja Bonca 557 Nearly a Posting Maven

Example:

public DataTable distanciaEclidiana(DataTable dt, DataRow distRefRow, List<string> campos)
{
    DataTable newTable = new DataTable("OneColumnTable");
    table.Columns.Add("Dist", typeof(float));
    DataRow row;
    foreach(DataRow dr in dt.Rows)
    {
        float soma = 0;
        foreach (string col in campos)
        {
            soma += (float)Math.Pow(Convert.ToDouble(distRefRow[col]) - Convert.ToDouble(dr[col]), 2);
        }
        row = table.NewRow();
        row["Dist"] = (float)Math.Sqrt(soma);
    }
    return table;
}

Now you will be reaturning DataTable!!! Dont forget to change the code on returning.

I am not sure what you need some column, but you can simple add data from the created dataTable to some other.

I hope this it it,
bye

Mitja Bonca 557 Nearly a Posting Maven

You cannot add rows to dataColumn. You can ONLY add then to dataTable. DataColumn is only a "part" of dataTable, as it is Datarow.
So what i suggest you, is that you add new column to dataTable, and then add data to this column (you do NOT need to add rows, because rows already exists).

If you dont want to add column to existing datatable, create a NEW dataTable, and then create a new datacolumn (as you already did) and then use table.NewRow() method.

Mitja Bonca 557 Nearly a Posting Maven

Put Listener.Start() method, just under where you create a reference of TcpListener, so like:

private void initiateListen()
{
    //Tcp
    this.tcpListener = new TcpListener(IPAddress.Any, portnumber);
    tcpListener.Start(); //HERE!!
    //why you have this code bellow??
    //you need a new variable to get Port no:
    int intPort = Convert.ToInt32(portnotxt.Text.Trim());
    this.threadTcp = new Thread(new ThreadStart(ListenToClients));
}