Mitja Bonca 557 Nearly a Posting Maven

I am not sure that that's exactly what I need. Your code helps to connect textboxes of form1 and form2 but I want to sent the text from form2 to form2.

On a button click or how?

And lets say you open 3 form2.
In one of them you write some text. And when pressing a button, you want this text to be sent to other 2 form2?

Mitja Bonca 557 Nearly a Posting Maven

Do you get any value into variable "listOfReservationTables" ?
Or is it null?
Put a break point to see if the method returns any value.

Mitja Bonca 557 Nearly a Posting Maven

You can use a get set modifier ( a static one, so you will not need to initialize a new form1), and one time you read the text from it, 2nd time you set the text from it:

//Form1:
       public static string MyText { get; set; } //this is the point of all here!

        public Form1()
        {
            InitializeComponent();
        }

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

//Form2:
        public Form2()
        {
            InitializeComponent();

            //1st: read the text if exist:
            this.textBox1.Text = Form1.MyText; 
      
            //2nd create an event which will pass characters to get,set modifier:
            this.textBox1.TextChanged += new EventHandler(textBox1_TextChanged);
        }

        private void textBox1_TextChanged(object sender, EventArgs e)
        {
            //set the text:
            Form1.MyText = textBox1.Text;
        }
Mitja Bonca 557 Nearly a Posting Maven

You might want to do it like this (I said might, because I am not sure about what "listOfReservationTables" include).

for (int a = 0; a < dgvReservation.Rows.Count; a++)
            { 
                int reservationID = Convert.ToInt32(dgvReservation[0, a].Value); //add ToString() if necessary.
                List<int> listOfReservationTables = mgrTableReservation.GetReservationTablesByReservationID(reservationID); 
                dgvReservation[7, a].Value = listOfReservationTables.Count; 
            }

I am not sure what value would like to show in column 8, so if this solution is not it, let me know what is would be, so I can help you out with the correct value.

Mitja Bonca 557 Nearly a Posting Maven

Ar you sure your 8th column shows this value? Because you stated it as column index no. 7.
And one more think: what is it doing this loop:

foreach (int t in listOfReservationTables)
                {
                    tables = tables + "," + t.ToString();
                }

This for sure is not summing up the int values, becuase you cannot sum values of type string.

Mitja Bonca 557 Nearly a Posting Maven

So, have you found the problem yet?

Mitja Bonca 557 Nearly a Posting Maven

Maybe you didn`t set the shortcut of the project correctly.
Then I dont know what could be else. As a matter of fact, nothing can be wrong.
Or some missing prerequisites, or there is something wrong with starting your application - so the shortcut to run the exe file.

Mitja Bonca 557 Nearly a Posting Maven

If you included all what you use in the project, it shoud work after publishing and installing the project.

And if you run the project from VS there is no problem at all? Go thorugh all the code from the beginning with putting a break point. Check what might be wrong, if there is any special code included (thaqt code which might use some prerequisites).

Mitja Bonca 557 Nearly a Posting Maven

Do it this way:

Private NewMDIChild As frmReportProblem
Private Sub miReportProblem_Click(sender As System.Object, e As System.EventArgs)
	If NewMDIChild Is Nothing Then
		NewMDIChild = New frmReportProblem()
		NewMDIChild.MdiParent = Me
		NewMDIChild.Show()
	End If
End Sub
Mitja Bonca 557 Nearly a Posting Maven

Why is your method type of string. You want to get a number, number of comments, so you should work and return an integer.

What represents this line of code:

var comment = db.DMSDataContext.Comments.Where(p => Convert.ToString(p.IdTopic) == IdTopic);

I see you aretrying to use Linq query over some objects. Do you get any value in the "comment" varible?
I presume that "var comment" represents an <int> object, so we can convert this to integer
if so then you can do:

private void YourMainMethod()
    {
        //get comments:
       int intComments = GetCountComment("some id");
       if(intComments == 0)
            window.alert("There is no comments found.");
    }
    
    protected int GetCountComment(string IdTopik)
    {
       string value = String.Empty;
       DMSDataAccess db = new DMSDataAccess();
       var comment = db.DMSDataContext.Comments.Where(p => Convert.ToString(p.IdTopic) == IdTopic);
       return value;       
    }
Mitja Bonca 557 Nearly a Posting Maven

Check out this code:

Private Sub textBox1_KeyPress(sender As Object, e As KeyPressEventArgs)
	'allows backspace key
	If e.KeyChar <> ControlChars.Back Then
		'allows just number keys
		e.Handled = Not Char.IsNumber(e.KeyChar)
	End If
End Sub
Mitja Bonca 557 Nearly a Posting Maven

i think you missing some component while making DLL setup. make new setup and try with other OS

??
1st of all, that`s a part what I explained, and your 2nd statement has no point.
Or you do a complete explanation, or you better do nothing. Iam sure he has no clue what were you talking about (even I am hardly awaring of what you were saying).

Please, next time do better work... ok?

Mitja Bonca 557 Nearly a Posting Maven

This is another version of updating Label`s text over the thread:

delegate void LabelDelegate(string message);
        public Form1()
        {
            InitializeComponent();         
        }

        private void UpdatingLabel(string msg)
        {
            if (this.label1.InvokeRequired)
                this.label1.Invoke(new LabelDelegate(UpdatingLabel), new object[] { msg });
            else
                this.label1.Text = msg;
        }

Its faster and easier...

Mitja Bonca 557 Nearly a Posting Maven

Did you forget to include any reference or application files to the installer?

Go to your project, into Solution explorer, right mouse click on the Project name, and select Properties. Go to Publish tab, and click on Application Files and Prerequisites.
Check in both if there is anything missed out not be included in the installer version.

Mitja Bonca 557 Nearly a Posting Maven

This book you are using, uses some strange expressions. It should be written like:
Create a dataTable, then do an sql query to fill this table up, and bind it to the dataGridView.
In the code this would look like:

DataTable table;

        private void GetData()  //call this method when ever you want to populate dgv!
        {
            using (SqlConnection sqlConn = new SqlConnection("ConnectionString"))
            {
                //get data from dataBase:
                string sqlQuery = @"SELECT * FROM MyTable"; //use your own sql query!!!
                SqlCommand cmd = new SqlCommand(sqlQuery, sqlConn);
                //if you need any parameter for the sqlCommand you do:
                //cmd.Parameters.Add("@paramName", SqlDbType.Int).Value = "Some value";
                SqlDataAdapter da = new SqlDataAdapter(cmd);
                table = new DataTable("MyTable");

                //fill table with sql inquery:
                da.Fill(table);
            }

            //set dataTable as a binding source to the dgv:
            dataGridView1.DataSource = new BindingSource(table, null);
        }
Mitja Bonca 557 Nearly a Posting Maven

Deal!

Mitja Bonca 557 Nearly a Posting Maven

Hi, this is a bit more complicated as I thought. I knew I have to se CellValidating event, but there is quite some code, as you can see.
You can see Iam giving yo u a whole code I wrote, including with my example data (this one you can delete).

I have to say I tested it, and it works. Maybe there will appear any error after some time (Iam not 100% sure right now, that is all included), but it should work - at least for me it did!

This code as you can see has 2 columns (remember, this is only an example code, meant to show the point how it should work), 1st column is an Id (Column1), and there are numbers (it does not matter what it is, it could be the strings as well). And when you enter a new number into a new row, if this number is NOT yet included in the dataSource of dateGridView, it will all be OK. If this number already exists, you will get a warning. And you will be forced to insert a new one, which does not exist in the dataSource.

Take a look:

DataSet ds;
        string oldValue;
        public Form1()
        {
            InitializeComponent();            

            //
            //you can erase this code bellow, because you will create your own datSet!!
            //

            //creating dataSet (with dataTable):
            ds = new DataSet();
            DataTable table = new DataTable("MyTable");
            DataColumn[] columns = new DataColumn[]
            {
                new DataColumn("Column1", typeof(int)),
                new DataColumn("Column2", typeof(string)) …
Mitja Bonca 557 Nearly a Posting Maven

Do you populate dgv with all the "layout id" from the database? I means are the all rows from dataBase, present in the dgv?

And how do you populate dgv? Is it data bound, or not? If it is, you can loop through the dataTable of particular column, and check if the value exists or not. Then dedice what to do if the value is found or not.

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

I did repair the code, and it should work now:

private void updatetaskstatus()
        {
            using(SqlConnection con = new SqlConnection())
			{
				con.ConnectionString = "Data Source=.\\SQLEXPRESS;AttachDbFilename=C:\\Effort Tracker System\\Effort Tracker System\\ETS.mdf;Integrated Security=True;Connect Timeout=30;User Instance=True";
            
				SqlCommand cmd1 = new SqlCommand("SELECT Task FROM tblTask", con);
				con.Open();
				using(SqlDataReader alltasks = cmd1.ExecuteReader())
				{
					while (alltasks.Read())
					{
						string comp = "Completed";
						string tTask = (string)alltasks[0];

						SqlCommand cmd2 = new SqlCommand("SELECT count(*) FROM tblDaily_Task_Schedule WHERE " +
						"tblDaily_Task_Schedule.Task = @Task", con);
						cmd2.Parameters.Add("@Task", SqlDbType, Int). Value = tTask;
						int counter = Convert.ToInt32(cmd2.ExecuteScalar());

						SqlCommand cmd3 = new SqlCommand(
						"SELECT count(*) FROM tblDaily_Task_Schedule WHERE " +
						"tblDaily_Task_Schedule.Task = @Task AND " +
						"tblDaily_Task_Schedule.Task_Status = @TaskStatus" , con);
						cmd3.Parameters.Add("@TaskStatus", SqlDbType, VarChar, 50). Value = comp;
						int counter2 = Convert.ToInt32(cmd3.ExecuteScalar());
                    
						if (counter == counter2)
						{
							try
							{
								string ya = "Yes";
								SqlCommand cmd4 = new SqlCommand(
								"UPDATE tblTask SET Completed = @Completed WHERE Task = @Task", con);
								cmd4.Parameters.Add("@Completed", SqlDbType, VarChar, 50). Value = ya;
								cmd4.Parameters.Add("@Task", SqlDbType, Int). Value = tTask;                
								//	Execute the query
								cmd4.ExecuteNonQuery();
							}
							catch (Exception ex)
							{
								MessageBox.Show(ex.Message);
							}							
						}
					}
				}
			}
        }
Mitja Bonca 557 Nearly a Posting Maven

virusisfound, Have you salved the problem regarding this thread?

Mitja Bonca 557 Nearly a Posting Maven

Simple, use object for the value. This how you initialize a new Dictionary:

Dictionary<int, object> dic = new Dictionary<int, object>();
dic.Add(1, "some value");
dic.Add(2, 3.4);
dic.Add83, true);
dic.Add("other value");

As you can see, if you use object, you can use any type of value as you like.

Mitja Bonca 557 Nearly a Posting Maven

Try this code, it works 100%:

private void WriteToFile()
        {
            string line = "-0.025 0.15 0.15 0.4 0.5 -0.05 0.1333333 0.2 0.4 0.5 -0.05 0.1333333 0.2 0.4 0.5 -0.05 0.1333333 0.2 0.4 0.5 -0.05 0.1333333 0.2 0.4 0.5";
            string path = @"C:\1\test27.txt";
            using (FileStream fs = new FileStream(path, FileMode.OpenOrCreate))
            {
                using (TextWriter tw = new StreamWriter(fs))
                {
                    string[] array = line.Split(' ');
                    string textToWrite = null;
                    for (int i = 1; i <= array.Length; i++)
                    {
                        if (i % 5 == 0 && i > 1)
                        {
                            textToWrite += array[i - 1];
                            tw.WriteLine(textToWrite);
                            textToWrite = null;
                        }
                        else
                            textToWrite += array[i - 1] + " ";
                    }
                }
            }
        }
Mitja Bonca 557 Nearly a Posting Maven

GridView is a grid consisted by the rows and columns. Each row and column gather a cell. You can change, add or delete every cell, row and column.

ReportView - I would assume that this is ReportViewer. Its meant to show data to print (like CrystalReportViewer).

Mitja Bonca 557 Nearly a Posting Maven

You have to get strings seperately from that control, and later join both into a dateTime:

string a = tpReservationDate.Value.ToLongDateString();
string b = tdtpEventTime.Value.ToLongTimeString();
DateTime date = Convert.ToDateTime(a + " " + b);

//Example:         
string a = "13.3.2011";
string b = "13:54:32";
DateTime date = Convert.ToDateTime(a + " " + b);
Mitja Bonca 557 Nearly a Posting Maven

To answer on your last question, you can easily do if you will use my code with a genric list:

private void button1_Click(object sender, EventArgs e)
        {
            //get 1. ip from the list (if there are many):
            textBox1.Text = list.Select(s => s.IPport).First();
            textBox2.Text = list.Select(s => s.Gate).First();
        }
Mitja Bonca 557 Nearly a Posting Maven

There is maybe a bit different approach, to use a generic list, which will save all the IPs and their gates.

List<MyIP> list;
        private void ReadFile_WithIP()
        {
            list = new List<MyIP>();
            using (StreamReader sr = new StreamReader(@"C:\YourFolder\YourFileName"))
            {
                string line;
                while ((line = sr.ReadLine()) != null)
                {
                    string[] array = line.Split(':');
                    MyIP _ip = new MyIP();
                    _ip.IPport = array[0];
                    _ip.Gate = array[1];
                    list.Add(_ip);
                }
            }
        }

        internal class MyIP
        {
            public string IPport { get; set; }
            public string Gate { get; set; }
        }

To get all our your can do it:

foreach (MyIP _ip in list)
            {
                string _ipPort = _ip.IPport;
                string _gate = _ip.Gate;
            }
Mitja Bonca 557 Nearly a Posting Maven

So, does your code work like you want to?

Mitja Bonca 557 Nearly a Posting Maven

YOu cannot read a whole row of the dgv to a string. Ok, you can, but there will be no value you want to have. So you have to specify from which column and from which row you want to get the value.

Lets repair your code:

//just make sure you initialize SqlConnection!!
            cn.ConnectionString = "Data Source=sam-AB59A9C19;Initial Catalog=master;Integrated Security=True";                                  
            string cd = dataGridView1[0, e.RowIndex].Value.ToString(); //0 represens the 1st column 
            //!!! change the number to the column you want to get the correct value !!!

            string CommandText = "select * from acc where id = @id";
            SqlCommand cmd = new SqlCommand(CommandText, cn);
            cmd.Connection = cn;
            cmd.Parameters.Add("@id", System.Data.SqlDbType.VarChar, 20).Value = cd;
            cn.Open();  
            SqlDataReader rdr = cmd.ExecuteReader();
            while (rdr.Read())
            {
                textBox1.Text = (string)rdr[0];
                textBox2.Text = (string)rdr[1];   
                textBox3.Text = (string)rdr[2];
            }
            cn.Close();

This should work.

Mitja Bonca 557 Nearly a Posting Maven

Lets clear some things now, and lets look into your example code:

DateTime dateOfEvent = Convert.ToDateTime(dtpReservationDate.Value.ToLongDateString());

You dont need to assign a method "ToLongDateString()", because you want to get a real DateTime value. And real dateTime value has nothing to do with the string date (or string time).
It would be enough to write:

DateTime dateOfEvent = dtpReservationDate.Value; //if this is some kind of dateTimePicker or monthCalendar
//if not, you do:
DateTime dateOfEvent = Convert.ToDateTime(dtpReservationDate.Value); //this should do it in the worst case scenario

... so you want now what exactly? I didnt get your question.
If you only want to pass the variable to another field or propery you can do:

DateTime dateTimeOfEvent = dateOfEvent;

Because every real DateTime value will have all (date and time). If this will not be possible to convert, you will get an error before that (in the upper code you pasted - for example).

Mitja Bonca 557 Nearly a Posting Maven

Hello :)
in your 2nd example, the code will not get through. Code will compile, but will be an error on line 3). You will get an error "Object reference not set to an instance of an object.". Thats because a1 was not instantiated yet, and thats why you cannot reach "field" property (or field) on asd class (yet).

1st code looks defenatelly ok.

Mitja Bonca 557 Nearly a Posting Maven

That you can return T. Becuase the method is a return type of <T>. If there is no specific return type in the method name, you are unable to return it.

In your 2nd example you can return T vlaue, when in your 1st can not.

Mitja Bonca 557 Nearly a Posting Maven

Depends, if your return that type of not. If you do not return, then your method does not need to be a type of <T>, otherwise is has to be.
Example:

static List<T> GetInitializedList<T>(T value, int count)
    {
	// This generic method returns a List with ten elements initialized.
	// ... It uses a type parameter.
	// ... It uses the "open type" T.
	List<T> list = new List<T>();
	for (int i = 0; i < count; i++)
	{
	    list.Add(value);
	}
	return list;
    }

    static void Main()
    {
	// Use the generic method.
	// ... Specifying the type parameter is optional here.
	// ... Then print the results.
	List<bool> list1 = GetInitializedList(true, 5);
	List<string> list2 = GetInitializedList<string>("Perls", 3);
	foreach (bool value in list1)
	{
	    Console.WriteLine(value);
	}
	foreach (string value in list2)
	{
	    Console.WriteLine(value);
	}
    }
ddanbe commented: Good explanation. +9
Mitja Bonca 557 Nearly a Posting Maven

I would say there is no difference, just that the your 1st example shows to which property some value is relied to. But if you know what you are doing, and know code well, its surely better to use 2nd option, which is the same as 1st one, but faster to write (execution time is the same tho).

Mitja Bonca 557 Nearly a Posting Maven

Are you talking about generic method?
If the operations performed by several overloaded methods are identical for each argument type, the overloaded methods can be more compactly and conveniently coded using a generic method. You can write a single generic method declaration that can be called at different times with arguments of different types. Based on the types of the arguments passed to the generic method, the compiler handles each method call appropriately.

here is an example code:

static void Main( string[] args )
     {
         // create arrays of int, double and char
         int[] intArray = { 1, 2, 3, 4, 5, 6 };
         double[] doubleArray = { 1.1, 2.2, 3.3, 4.4, 5.5, 6.6, 7.7 };
         char[] charArray = { 'H', 'E', 'L', 'L', 'O' };
   
         Console.WriteLine( "Array intArray contains:" );
         PrintArray( intArray ); // pass an int array argument
         Console.WriteLine( "Array doubleArray contains:" );
         PrintArray( doubleArray ); // pass a double array argument
         Console.WriteLine( "Array charArray contains:" );
         PrintArray( charArray ); // pass a char array argument
      } // end Main
   
      // output array of all types
      static void PrintArray< E >( E[] inputArray )
      {
         foreach ( E element in inputArray )
            Console.Write( element + " " );
   
         Console.WriteLine( "\n" );
      } // end method PrintArray
  } // end class Generic method
vedro-compota commented: ++++++ +1
Mitja Bonca 557 Nearly a Posting Maven

What type is your list?
is it: List<double[]> ?

Mitja Bonca 557 Nearly a Posting Maven

I dont know what your list represents. So it would be good to add some code or explanation to the thread.

Check out my code I did yesterday here:
http://www.daniweb.com/software-development/csharp/threads/360495

As you can see Iam creating a dictionary, and use generic list<T> as Value.
This how you can get values of the columns together, and then you can do math operations over them.

Mitja Bonca 557 Nearly a Posting Maven

Check out this code. The 1st part is only a simple dgv population. Then is the code which color the rows:

public Form1()
        {
            InitializeComponent();
            dataGridView1.Columns.Add("col1", "column 1");
            dataGridView1.Columns.Add("col2", "column 2");
            dataGridView1.Rows.Add(1, "Canceled");
            dataGridView1.Rows.Add(2, "Ok");
            dataGridView1.Rows.Add(3, "Canceled");
            dataGridView1.Rows.Add(4, "Canceled");
            dataGridView1.Rows.Add(5, "Ok");

            foreach (DataGridViewRow row in dataGridView1.Rows)
            {
                if (dataGridView1["col2", row.Index].Value != null)
                    if (dataGridView1["col2", row.Index].Value.ToString() == "Canceled")
                        row.DefaultCellStyle.BackColor = Color.Red;
            }
        }

It works.

Mitja Bonca 557 Nearly a Posting Maven

Hi,
would you mind telling us some more about what would you like to achive?
I mean what is the source, and what to put together and the output of course.

Otherwise salving problems when you have a key and multiple value can really be salved with the Dictionary collections, and for the Dictionary`s value you can use generic list<T>:

Dictionary<string, List<string>> dic = new Dictionary<string, List<string>>();
//1st key:
dic.Add("key1", new List<string>{"value1_of_key1"};
dic["key1"].Add("value2_of_key1");
// and so on for the key 1

//for 2nd key:
dic.Add("key2", new List<string>{"value1_of_key2"};
dic["key2"].Add("value2_of_key2");
//and so on..
//and for the rest of the keys...
Mitja Bonca 557 Nearly a Posting Maven

if you want to check if the value is not null:

while (r.Read())
{  
   if(r.GetValue(1) != DbNull.Value)
     string name = (string)r[1];
   //and so on for the rest of the fields...
}
Mitja Bonca 557 Nearly a Posting Maven

If you want to set all to true then you can do:

foreach (DataGridViewRow row in dataGridView1.Rows)
      {
        DataGridViewCheckBoxCell chk = row.Cells[0] as DataGridViewCheckBoxCell;
        if (Convert.ToBoolean(chk.Value) == false)
            chk.Value = true;
      }

If you want to set for a specific row:

foreach (DataGridViewRow row in dataGridView1.Rows)
      {
          if(row.index == dataGridView1.CurrentCell.RowIndex)
          {
              DataGridViewCheckBoxCell chk = row.Cells[0] as DataGridViewCheckBoxCell;
              if (Convert.ToBoolean(chk.Value) == false)
                  chk.Value = true;
          }
      }
Mitja Bonca 557 Nearly a Posting Maven

Iam glad you are satisfied. There are still areas to improve the code, but one step at the time.
You should also consider doing this code in 3 tier architecture. It means you build your project, expecially when you work with dataBase, in seperated classes. Access to the database is 1st class (DAL - Data Access Layer), if there is any code to do any calculations and other stuff is 2nd class (BLL -Business Logic Layer), and the last one (3rd) is the GUI (Grapgical User Interface).

But as said, one step at the time.

Mitja Bonca 557 Nearly a Posting Maven

Create a new DataTable and fill it up with the values from all those fields (in dataBase), using a correct query:

private void ShowData()
{
    int scheduledId = 1; //some example
    DataTable table = GetData(scheduledId);
    if(table.Rows.Count > 0)
    {
         //use data from dataTable to populate some contols, or dataGridView.
         //1. if controls, like textboxes
         foreach(DataRow dr in table.Rows)
         {
             textBox1.Text = dr[0].Tostring(); //index 0 is 1st column!
             //and so on...
         }

         //2. is you want to populate dataGridView, you can set table as a data source to dgv:
         //no need to create columns and stuff for dgv (it will create all automatically)
         dataGridView1.DataSource = new BindingSource(table, null);
    }
}
private DataTable GetData(int ScheduledEventID)
{
     SqlConnection sqlConn = new SqlConnection("connString");
     string query = @"Select * from ScheduledEvents where ScheduledEventID = @id";
     SqlCommand cmd = new SqlCommand(query, sqlConn);
     cmd.Parameters.Add("@id", SqlDbType.Int).Value = ScheduledEventID;
     SqlDataAdapter da = new SqlDataAdapter(cmd);
     DataTable table = new DataTable("MyTable");
     da.Fill(table);
     return table;
}

I hope this helps explaining how you get data and use them later in populating controls.

johnt68 commented: Always really helpful - thank you +1
Mitja Bonca 557 Nearly a Posting Maven

What is wrong with this code? You only posted two methods, which can tell me nothing.
You have to be more precise about what do you want to achive.
Can you please do a bit better explanation, or add some more code? It would really help out.

Mitja Bonca 557 Nearly a Posting Maven

The "newNumbers" will be: 1,5 and 9.
I think this is what you have been looking for.

Mitja Bonca 557 Nearly a Posting Maven

Here you have an example code of multipidimensional array, and how to get values out of it:

int[,] array = new int[3, 4] { { 1, 2, 3, 4 }, { 5, 6, 7, 8 }, { 9, 10, 11, 12 } };
            int[] newNumbers = null;
            for (int i = 0; i < array.GetLength(1); i++)
            {
                for (int j = 0; j < array.GetLength(0); j++)
                {
                    Array.Resize(ref newNumbers, (j + 1));
                    newNumbers[j] = array[j, i];
                }
                break;
            }
Mitja Bonca 557 Nearly a Posting Maven

You can create as many constructors as you like. One can have no parameters, 2nd can have one, 3rd constructor can have 3 parameters and so on.
When you create a new instance of a class you then pass as many parameters as you have in those constructors. It will be called that constructor with the same number of parameters.

Can you clarify your statements from post 1 a bit better? I didnt understand it.

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

Instead of reading whole text, and then split the lines, you can get all lines into an array directly:

string[] lines = File.ReadAllLines(@"C:\file.txt");
Mitja Bonca 557 Nearly a Posting Maven

I changed my mind, I will rather use a dictionary. Its even better tool to use, and most important, you will not have n number of Lists (n = undefined).
This is the solutuion for you:

private void GetDataFromFile()
        {
            Dictionary<int, List<int>> dic = new Dictionary<int, List<int>>();
            string tag = "[HRData]";
            string path = @"C:\1\test26.txt";
            using (StreamReader sr = new StreamReader(path))
            {
                string line;
                int counter;
                while ((line = sr.ReadLine()) != null)
                {
                    if (line != tag)
                    {
                        counter = 1;
                        string[] lineData = line.Split('\t');
                        foreach (string data in lineData)
                        {
                            int number = Convert.ToInt32(data);
                            if (!dic.ContainsKey(counter))
                                dic.Add(counter, new List<int> { number });
                            else
                                dic[counter].Add(number);
                            counter++;
                        }
                    }
                }
            }

            //getting data of sinlge column:
            StringBuilder sb = new StringBuilder();
            foreach (KeyValuePair<int, List<int>> kvp in dic)
            {
                var sum = kvp.Value.Sum();
                sb.AppendLine("Column " + kvp.Key.ToString() + ": " + sum.ToString());
            }
            MessageBox.Show("This is the result of summing all the columns:\n" + sb.ToString());
        }

I hope I will get a beer now :)

ddanbe commented: Cheers! Prosit! +9
Mitja Bonca 557 Nearly a Posting Maven

If you want to get together the data in individual column, you better create as many arrays (or even better generic lists) as you have columns. When you will read line by line, you put 1st value into 1st column, 2nd value into 2nd column, and so on.
On the end you will have (in your particular case) 6 arrays and you can easily do an average (sum all and divinde with the number of numbers).
As simple as that.