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

Hi, you will have to use convert image to a byte array and then back to image.

'server/write
        Dim len As Long = sendBytes.Length

        Dim Bytelen() As Byte = BitConverter.GetBytes(len)
        'send the size of Data first
        networkStream.Write(Bytelen, 0, Bytelen.Length)
        'add write size of Data 2011/3/3

        networkStream.Write(sendBytes, 0, sendBytes.Length)
'-----------------------------------------------------------------------
          'client/read
          ' add read size of Data 2011/3/3
          Dim len As Long
          Dim byteLen(8) As Byte
          'read the size of data
          networkStream.Read(byteLen, 0, 8)
          len = BitConverter.ToInt64(byteLen, 0)
          ' add read size of Data 2011/3/3

          'Dim bytes(tcpClient.ReceiveBufferSize) As Byte
          Dim bytes(len) As Byte

          'networkStream.Read(bytes, 0, CInt(tcpClient.ReceiveBufferSize))
          networkStream.Read(bytes, 0, len)
Mitja Bonca 557 Nearly a Posting Maven

Try using TextmWriter object:

Dim text1 As String = "Some text in the line"
Dim text2 As String() = {"a", "b", "c"}
Dim path As String = "c:\myFile.txt"
'fill will be create (if not exists) on the c: drive
Using fs As New FileStream(path, FileMode.OpenOrCreate)
	Using tw As TextWriter = New StreamWriter(fs)
		tw.WriteLine(text1)
		For Each str As String In text2
			tw.WriteLine(str)
		Next
	End Using
End Using

About the upper example, it should be working, at least if the "fileName" contains the correct path:

Dim filePath As String = "C:\1\testFile234.txt"
Dim sTemp As String = "my database value goes here1"
System.IO.File.WriteAllText(filePath, sTemp)
'but this will always re-write the whole file (if any text previously in the file, it will be gone, only a new one will be inserted!
Mitja Bonca 557 Nearly a Posting Maven

I hope this thing is not one method Mitja. This is what is commonly referred to as a code smell.

Btw, you could tell us where this error uccur. I wont look not the whole code to find you the error in it.

Mitja Bonca 557 Nearly a Posting Maven

Hello
would you mind telling to Sort what exactly?
An array, listArray, generic list<T>, dictionary collections, or else?

You have to be specific, and which technique do you want to use?

For the Arrays there is a method "Sort" avaiable, then you have a Linq, a very powerful tool in C# (since version 2.0 and leter). Using Lambda Expressions, allows you to do almost any kind of sorting and stuff.
In linq you use methods like "Sort, and OrderBy, but a bit differently then for the Array.

//1. array Sort:
            string[] strArray = { "b", "d", "a" };
            int[] intArray = { 23, 43, 3, 2 };
            Array.Sort(strArray); //asc
            Array.Reverse(strArray); //des
            Array.Sort(intArray);//asc            

            //2.Linq on generic List<T>:
            List<string> list1 = new List<string>();
            list1.AddRange(new string[] { "b", "d", "a" });
            list1 = list1.OrderBy(o => o[0]).ToList();

            List<int> list2 = new List<int>();
            list2.AddRange(new int[] { 23, 43, 3, 2 });
            list2.Sort((x, y) => Convert.ToInt32(x).CompareTo(Convert.ToInt32(y)));
            //to show results:
            foreach (int number in list2)
            { 
             //number is the value (one by one - in sorted ascending order!
            }
Mitja Bonca 557 Nearly a Posting Maven

If I understand you well, you would like to copy content of the dataBase to a textFile. But only the data, or th whole structure, like sql has with "Export" option?

Mitja Bonca 557 Nearly a Posting Maven

Defenatelly. Expired version in useless now. I am a student too, and I got a lot of software from Microsoft for free as well. Why not using it, if its leagal, and free of charge.

Mitja Bonca 557 Nearly a Posting Maven

If you are updating an existing row in the dataTable, you MUST put a comparison, this is a WHERE clause in the sql query.
And you cannot update ID, which is a uniqe key. The Id you have to use to compare which row you have to update.
How you will get this Id its up to you, but you should have got it, before when you did a select query (and remember it some how).
The query should look like this:

da.UpdateCommand = new SqlCommand("Update Lib_book_details set book_name=@book_name,book_author_name=@book_author_name where book_category_id=@book_category_id [B]WHERE book_tag_id=@book_tag_id[/B]", cs);
Mitja Bonca 557 Nearly a Posting Maven

The problem is in your Select statement. You only select one value (address1), but in the read you want to retreive two values (reader[0] and reader[1]).
Solution: or you add two values into select statement, or you remove reader[1] from the while loop.
1.:

cmd.CommandText = "select address1, address2 from lalocation where servicenumber < 11";
            SqlDataReader reader = cmd.ExecuteReader();
            while (reader.Read())            
                Console.WriteLine(reader[0].ToString() + " " + reader[1].ToString());

2.:

cmd.CommandText = "select address1from lalocation where servicenumber < 11";
            SqlDataReader reader = cmd.ExecuteReader();
            while (reader.Read())            
                Console.WriteLine(reader[0].ToString());
Mitja Bonca 557 Nearly a Posting Maven

Hi,
i did the code for you, I hope I have understood you well.
Check it out, and let me know:

Public Partial Class Form1
	Inherits Form
	Private bList As BindingList(Of Game)
	Private list As List(Of ListCheck)
	Public Sub New()
		InitializeComponent()
		dataGridView1.CurrentCellDirtyStateChanged += New EventHandler(AddressOf dataGridView1_CurrentCellDirtyStateChanged)
		dataGridView1.CellValueChanged += New DataGridViewCellEventHandler(AddressOf dataGridView1_CellValueChanged)

		'creating a binding source:
		bList = New BindingList(Of Game)()
		bList.Add(New Game() With { _
			Key .CardNumber = 2233, _
			Key .Name = "Lyn", _
			Key .DoorAccess = "Testing", _
			Key .Tick1 = False, _
			Key .LifeAccess = "-", _
			Key .Tick2 = False _
		})
		bList.Add(New Game() With { _
			Key .CardNumber = 1999, _
			Key .Name = "Matt", _
			Key .DoorAccess = "-", _
			Key .Tick1 = False, _
			Key .LifeAccess = "FreeAcc", _
			Key .Tick2 = False _
		})
		dataGridView1.DataSource = New BindingSource(bList, Nothing)

		'setting some properties of dgv:
		dataGridView1.AllowUserToAddRows = False
		'dataGridView1.AutoResizeColumns(DataGridViewAutoSizeColumnsMode.AllCells);
		dataGridView1.AutoSizeColumnsMode = DataGridViewAutoSizeColumnsMode.Fill

		'creating new custom list to save card number, and both checkBoxes:
		list = New List(Of ListCheck)()
	End Sub

	Private Sub dataGridView1_CurrentCellDirtyStateChanged(sender As Object, e As EventArgs)
		If dataGridView1.IsCurrentCellDirty Then
			dataGridView1.CommitEdit(DataGridViewDataErrorContexts.Commit)
		End If
	End Sub

	Private Sub dataGridView1_CellValueChanged(obj As Object, e As DataGridViewCellEventArgs)
		If e.ColumnIndex = 3 OrElse e.ColumnIndex = 5 Then
			'compare to checkBoxes column index
			Dim _tick1 As DataGridViewCheckBoxCell = TryCast(dataGridView1(3, e.RowIndex), DataGridViewCheckBoxCell)
			Dim _tick2 As DataGridViewCheckBoxCell = TryCast(dataGridView1(5, e.RowIndex), DataGridViewCheckBoxCell)
			Dim cardNo As Integer = Integer.Parse(dataGridView1(0, e.RowIndex).Value.ToString())

			'checking if the card Number exist in the list
			'if not, it addes a new card and values of …
Mitja Bonca 557 Nearly a Posting Maven

Is should be like this:

datagridview1.columns[1].HeaderText = "memberID";

columns at index 1 means that the code will chnage the header text in the 2nd column (looking from left to right).

Mitja Bonca 557 Nearly a Posting Maven

Would you mind telling me exactly what would you like to invert? I have no exact clue now, what you would you like to have. Thx in advance.

Mitja Bonca 557 Nearly a Posting Maven

How to invert?
From last to 1st? By which column (items, or subItems)?

I need more information.

Mitja Bonca 557 Nearly a Posting Maven

your query SELECT * FROM MenUsers,WomenUsers has no syntax problem check for the records in both the tables

As he said!
If your both tables DO NOT have the same column names, this is impossible to select.

Mitja Bonca 557 Nearly a Posting Maven

Becuase you cannot assign a null value to the Text property of the textBox.
You can do a checking if the value is null or not:

if(c.IDCardNumber != null)
     txtIDCardNo.Text = c.IDCardNumber.ToString();
else
     txtIDCardNo.Text = "";
Mitja Bonca 557 Nearly a Posting Maven

Why dont you better create two dataTable for Men and Women, and put both into the dataSet?

using (SqlConnection sqlConn = new SqlConnection("connString"))
            {
                DataSet ds = new DataSet();
                SqlDataAdapter da;
                SqlCommand cmd;
                DataTable table1 = new DataTable("Men");
                DataTable table2=new DataTable("Women");
                //fill men`s table:
                string query1 = @"SELECT * FROM Men";
                cmd = new SqlCommand(query1, sqlConn);
                da = new SqlDataAdapter(cmd);
                da.Fill(table1);
                //fill women`s table:
                string query2 = @"SELECT * FROM Women";
                cmd = new SqlCommand(query2, sqlConn);
                da = new SqlDataAdapter(cmd);
                da.Fill(table2);
            }
Mitja Bonca 557 Nearly a Posting Maven

Why? If you have a string and you want to split this string on (for example) "\r\n" - on a Enter key - new line, then why should bother using some other methods or ways, then, simply using a Split() method?

Is there any particular reason? Becuase I dont see it.
Can you show me an example of this string, and how it should look like?

Mitja Bonca 557 Nearly a Posting Maven

Any IDea how to Parse a String without using Split method

What do you means exactly?
Because there is pleanty of ways of "modifing" a string - all he string methods.

Mitja Bonca 557 Nearly a Posting Maven

For progressBar: Use a System.Windows.Timer class. You only have to get the total time and then set the beginning and the end of the timer. Use Tick event of the timer, to move the progressBar forward.
Heres an example:

private void InitializeMyTimer()
        {
            // Set the interval for the timer.
            time.Interval = 1000;
            // Connect the Tick event of the timer to its event handler.
            time.Tick += new EventHandler(IncreaseProgressBar);
            // Start the timer.
            time.Start();
        }

        //The following codes will make the progressbar increase the step one per time.

        void IncreaseProgressBar(Object sender, EventArgs e)
        {

            // Increment the value of the ProgressBar a value of one each time.
            progressBar1.Increment(1);

            if (progressBar1.Value == progressBar1.Maximum)
                // Stop the timer.
                time.Stop();
        }

About the playList. You have to get the files from specified directory and show only their Name.
Use a FileInto[] array to get and use them to play.

DirectoryInfo taskDirectory = new DirectoryInfo("specify full path to the directory with mp3 files");
FileInfo[] taskFiles = taskDirectory.GetFiles("*.mp3");
Mitja Bonca 557 Nearly a Posting Maven

I did a code, but didnt test it, becuase I did use any real files in example:

private void button1_Click(object sender, EventArgs e)
        {
            for (int i = 0; i < listView1.Items.Count; i++)
            {
                var someFile = new FileInfo(listView1.Items[i].Text);
                File.Move(someFile.FullName, listView1.Items[i].SubItems[1].Text);
                //the point is, that you have to specify two things inside the brackets:
                //1. Source file name (path where is the file now)
                //2. New file path!
            }
        }
Mitja Bonca 557 Nearly a Posting Maven

hdd = hard disc drive :)
About your code:
You can create a FileInfo array, and save them on the other location.
Does your listView has only one column or two? (fileName, and full file path)

Mitja Bonca 557 Nearly a Posting Maven

You mean to save files some place else on the hdd?

Mitja Bonca 557 Nearly a Posting Maven

Ok, I saw this post of yours, and what I want now is a decent explanation of the problem. I will not even look into code of yours, but I need some words what you need to do. Simple.

Mitja Bonca 557 Nearly a Posting Maven

Look, why dont you do as I showed you? It will work 100%.

Mitja Bonca 557 Nearly a Posting Maven

Would you mind showing me your code? This way I`ll better see what is wrong.
thx

Mitja Bonca 557 Nearly a Posting Maven

Forgot to say: You have to do an sql query to fill dataTable, but becuase I dont have this kind of dataBase, I filled it up by code (just example).

But what you really need it the 2nd part of the upper code.
bye

Mitja Bonca 557 Nearly a Posting Maven

Here is the working code:

Public Sub New()
	InitializeComponent()

	Dim ds As New DataSet()
	Dim table As New DataTable("MyTable")
	ds.Tables.Add(table)
	'my example columns creating and population:
	table.Columns.Add(New DataColumn("id", GetType(Integer)))
	table.Columns.Add(New DataColumn("code", GetType(String)))
	table.Columns.Add(New DataColumn("desc", GetType(String)))
	table.Rows.Add(1, "ADV", "ADVANCE")
	table.Rows.Add(2, "ADV", "ADVANCE")
	table.Rows.Add(3, "BUS", "BUS TICKET")
	table.Rows.Add(4, "BUS", "BUS TICKET")

	'create ListView:
	listView1.Columns.Add("Id", -2, HorizontalAlignment.Left)
	listView1.Columns.Add("Code", -2, HorizontalAlignment.Left)
	listView1.Columns.Add("Descriprion", -2, HorizontalAlignment.Left)
	listView1.View = View.Details
	listView1.FullRowSelect = True

	'do the selection of the dataTable:
	For Each dr As DataRow In ds.Tables("MyTable").Rows
		Dim bNewInsertion As Boolean = True
		For i As Integer = 0 To listView1.Items.Count - 1
			If dr(1).ToString() = listView1.Items(i).SubItems(1).Text Then
				bNewInsertion = False
				Exit For
			End If
		Next
		If bNewInsertion Then
			Dim lvi As New ListViewItem(dr(0).ToString())
			lvi.SubItems.Add(dr(1).ToString())
			lvi.SubItems.Add(dr(2).ToString())
			listView1.Items.Add(lvi)
		End If
	Next
End Sub
Mitja Bonca 557 Nearly a Posting Maven

hehe, We`ll be expecting you Moose :)
Dont be afraid to ask anything...

Mitja Bonca 557 Nearly a Posting Maven

Do it this way:

SaveFileDialog saveFileDialog1 = new SaveFileDialog();

            saveFileDialog1.Filter = "txt files (*.txt)|*.txt|All files (*.*)|*.*";
            saveFileDialog1.FilterIndex = 2;
            saveFileDialog1.RestoreDirectory = true;
            if (saveFileDialog1.ShowDialog() == DialogResult.OK)
            {
                //save file using textWriter object!
            }
Mitja Bonca 557 Nearly a Posting Maven

Then you dont need to initialize it (it already is!).
All you have to do, is to pass the form`s reference (this):

//SomeConstructor(this)
{

}
Mitja Bonca 557 Nearly a Posting Maven

??
Yes? some resonable explanation?

Mitja Bonca 557 Nearly a Posting Maven

YOu can do it this way:

//form1:
        public Form1()
        {
            InitializeComponent();
            label1.Text = "";
        }

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

        public void PassDataFromForm2(decimal value)
        {
            label1.Text = value.ToString();
        }

//form2:
        Form1 f1;
        public Form2(Form1 _f1)
        {
            InitializeComponent();
            this.f1 = _f1;
        }

        private void button1_Click(object sender, EventArgs e)
        {
            f1.PassDataFromForm2(numericUpDown1.Value);
        }
Mitja Bonca 557 Nearly a Posting Maven

Hello, so you have decided to do as I told you. Its sure the best idea (simple and fast).
You can use a ShowDialog method:

//form1:
     public partial class Form1 : Form
    {
        public static string Form2_Message { get; set; }
        public Form1()
        {
            InitializeComponent();
            label1.Text = "";
        }

        private void buttonMessage_Click(object sender, EventArgs e)
        {
            using (Form2 f2 = new Form2())
            {
                if (f2.ShowDialog() == DialogResult.OK)
                {
                    label1.Text = Form2_Message;
                }
                else
                    label1.Text = "";
            }
        }
    }

//form2 - MessageBox:
    public partial class Form2 : Form
    {
        public Form2()
        {
            InitializeComponent();
            this.Text = "My messageBox";
            label1.Text = "";
        }

        private void buttoConfirm_Click(object sender, EventArgs e)
        {
            if (textBox1.Text != String.Empty)
            {
                Form1.Form2_Message = textBox1.Text;
                this.DialogResult = DialogResult.OK;
            }
            else
                label1.Text = "Please write some message...";
        }

        private void buttonDecline_Click(object sender, EventArgs e)
        {
            this.DialogResult = DialogResult.Cancel;
        }
    }
Mitja Bonca 557 Nearly a Posting Maven

Sure it is. What you have to so, is to create a new Form, that will look like a messageBox. Put a textBox on it, and a buttons (Ok, Cancel, or what ever).
Simple.

Mitja Bonca 557 Nearly a Posting Maven

You have to pass a value to the 1st subitem of the listView, like that:

string name = "SomeName";
int id = 2;
ListViewItem lvi = new ListViewItem();
lvi.Text = name;
lvi-Subitems.Add(id.ToString());
listView1.Items.Add(lvi);

If you want to insert in a specific row, you have to create a loop of the listView`s rows:

for(int i = 0; i < listView1.Items.Count; i++)
{
    //same code here as abouve
}
Mitja Bonca 557 Nearly a Posting Maven

This is a base example of using connection string, but it works:

static string connString = @"Data Source=myServerAddress;Initial Catalog=myDataBase;User Id=myUsername;Password=myPassword;";
        private YourMethod()
        {
            using (SqlConnection sqlConn = new SqlConnection(connString))
            {
                sqlConn.Open();
                //do inquieries:
                string sqlQuery = @"SELECT ... FROM ... WHERE";
            }
        }

Use your correc connection string!

Mitja Bonca 557 Nearly a Posting Maven

Sure, you do not specify the table names. Look into my code, how I did it. I did named the dataTable, so it has a name, your do not have, because you fill dataTables (all togeter) in one stored procedure.

One more thing: the SqlDataAdapter will not look at the physical table names in your database to determine the table names in the ADO.NET DataSet. Sorry, there's really no way to do this automagically.

Why dont you create 3 sepersted stored procedures and use the code I did?

Mitja Bonca 557 Nearly a Posting Maven

How did your tables loose their names? Cant be?
If you do it right, the names will for sure stay (be there from the time of creation on...

YOu have to do code in C#, (create DataTable as well) and only call a storedProcedure (which only can include SELECT statement, nothing else), and fill in up:

DataSet ds = new DataSet();
        public Form1()
        {
            InitializeComponent();
        }

        private void GetData()
        {
            //DO THE SAME FOR EVERY SINLGE DATATABLE, LIKE THIS EXAMPLE:
            using (SqlConnection sqlConn = new SqlConnection("connString"))
            {
                SqlCommand cmd = new SqlCommand();
                cmd.CommandType = CommandType.StoredProcedure;
                cmd.CommandText = "YourProcedureName";
                cmd.Connection = sqlConn;
                SqlDataAdapter da = new SqlDataAdapter(cmd);
                DataTable table = new DataTable("MyTable1");
                ds.Tables.Add(table);
                da.Fill(table);
            }
        }

        private void ReadData()
        {
            DataTable table = ds.Tables["MyTable1"];
            foreach (DataRow dr in table.Rows)
            {
                //code to get each value form dataTable goes here
            }
        }

If you will do anything different, you will surely look tables, or something else.

Mitja Bonca 557 Nearly a Posting Maven

Simple. YOu simply add a name in the brackets of the ds.Tables:

DataTable myTable = ds.Tables["table_passenger_details"];
Mitja Bonca 557 Nearly a Posting Maven

Did you think about something like this:
PS: code is meant to work with 2 forms (form2, and form3). If you want for, add 2 more.

public partial class Form1 : Form
    {
        Form[] forms;
        Form2 f2;
        Form3 f3;
        int counter;
        public Form1()
        {
            InitializeComponent();
            forms = new Form[] { f2, f3 };
        }

        private void buttonFor_Click(object sender, EventArgs e)
        {           
            if (counter < forms.Length)
            {
                CommonMethod();
                counter++;
            }
        }

        private void buttonBack_Click(object sender, EventArgs e)
        {
            if (counter > 0)
            {
                counter--;
                CommonMethod();               
            }
        }

        private void CommonMethod()
        {
            for (int i = 0; i < forms.Length; i++)
            {
                if (forms[i] == null)
                {
                    if (i == 0)
                    {
                        f2 = new Form2();
                        forms[i] = f2;
                    }
                    else
                    {
                        f3 = new Form3();
                        forms[i] = f3;
                    }
                }
                if (counter == i)
                {
                    forms[i].Location = new Point((this.Location.X + this.Width + 10), this.Location.Y);
                    forms[i].Show();
                }
                else
                    forms[i].Hide();
            }
        }
    }

There is some work to be done, but this is working approximatelly.

Mitja Bonca 557 Nearly a Posting Maven

:)
You are welcome. Why I had to work? Hmm, you didnt let me step off, so I had to contine working. (btw, you can add a vote for me :) ).

If there is anything you dont know, come here, we`ll surely help you out.

Mitja Bonca 557 Nearly a Posting Maven

Hi, what is it that you would like to do exactly?

Mitja Bonca 557 Nearly a Posting Maven

Add parameters to the OldCommand and use the correct values for each of them (you said you have comboBoxes (in your upper example are textBoxes).
This is the code that should work:

Dim conn As New OleDbConnection("provider=microsoft.jet.OleDB.4.0;Data Source=" + Application.StartupPath & "\database.mdb")
Dim sql As String = String.Empty
sql = "insert into Pengurus(name, staffNo)" & "values (@value1, @value2) "
Try
	conn.Open()
	Dim Command As New OleDbCommand(sql, conn)

	'adding parameters:
	Command.Parameters.Add("@value1", OldDbType.VarChar, 50).Value = comboBox1.SelectedItem.ToString()
	Command.Parameters.Add("@value2", OleDbType.Int).Value = comboBox2.SelectedItem.ToString()
	Command.ExecuteNonQuery()
	conn.Close()
Catch
End Try
Mitja Bonca 557 Nearly a Posting Maven

I hope you are talking aobur DataTables. Simple name them by some uniqe name. If there is no other way, you can use numbers from 1 to 30 (as jockeyvn proposed), or use the name from sql table (table1, table2,table3 - if they are all different). Or use more sql table names, if there is any dataTable which has two or more sql tables (like: "... FROM Table1, Table2" - name dataTable as :Table1_Table2.

Remember its always good to name dataTables to something that you know what is in it (where it comes from). It easier to work. Thats why I would not recommend you to use numbers only.

Mitja Bonca 557 Nearly a Posting Maven

I did the whole code. There are now 2 forms. 1st one is like yours, and 2nd one is meant to add items.
Ok, here is a whole code:

//Form1:
    public partial class Form1 : Form
    {
        List<MyClass> list;
        public Form1()
        {
            InitializeComponent();

            //creating listView:
            listView1.Columns.Add("Item", 80, HorizontalAlignment.Left);
            listView1.Columns.Add("SubItem 1", 80, HorizontalAlignment.Left);
            listView1.Columns.Add("SubItem 2", -2, HorizontalAlignment.Center);
            listView1.View = View.Details;
            listView1.FullRowSelect = true;

            //create a new instance of a list<T>:
            list = new List<MyClass>();

            //populate list<T> (example code):
            AddingRows();

            //populating listView:
            ShowDataInListView();

            //creating comobBox`s event:
            this.comboBox1.SelectedIndexChanged += new EventHandler(comboBox1_SelectedIndexChanged);
            //some other event for adding and removing:
            this.buttonAdd.Click += new EventHandler(buttonAdd_Click);
            this.buttonRemove.Click += new EventHandler(buttonRemove_Click);
        }

        //EXAMPE CODE:
        private void AddingRows()
        {
            //some example population wtih 6 letters:
            string letters = "ABACADC";

            comboBox1.Items.Add("Show all");
            for (int i = 0; i < letters.Length; i++)
            {
                if (!comboBox1.Items.Contains(letters[i].ToString()))
                    comboBox1.Items.Add(letters[i].ToString());
                MyClass mc = new MyClass();
                mc.Item = "Item " + (i + 1);
                mc.SubItem1 = "SubItem " + (i + 1);
                mc.SubItem2 = letters[i].ToString();
                list.Add(mc);
            }            
        }

        //YOUR CODE TO ADD ROWS LATER ON:
        public void AddingRowsToList(string[] data)
        {
            //adding to list<T>:
            MyClass mc = new MyClass();
            mc.Item = data[0];
            mc.SubItem1 = data[1];
            mc.SubItem2 = data[2];
            list.Add(mc);

            //adding to comboBox if not exsits yet:
            if (!comboBox1.Items.Contains(data[2]))
                comboBox1.Items.Add(data[2]);

            //showing new data:
            ShowDataInListView();
        }

        private void ShowDataInListView()
        {
            listView1.Items.Clear();

            foreach (MyClass mc in list)
            {
                ListViewItem lvi = new ListViewItem(mc.Item);
                lvi.SubItems.Add(mc.SubItem1);
                lvi.SubItems.Add(mc.SubItem2);
                listView1.Items.Add(lvi);
            }
        }

        private void comboBox1_SelectedIndexChanged(object sender, EventArgs e)
        {
            string comboSelection = (string)comboBox1.SelectedItem;
            listView1.Items.Clear();
            foreach (MyClass mc in list)
            {
                if (comboSelection …
Mitja Bonca 557 Nearly a Posting Maven

I have finally understood what do you want, as soon as I have seen the form designer.
This is what I did for you:

namespace Apr23Test1
{
    public partial class Form1 : Form
    {
        List<MyClass> list;
        public Form1()
        {
            InitializeComponent();

            //creating listView:
            listView1.Columns.Add("Item", 80, HorizontalAlignment.Left);
            listView1.Columns.Add("SubItem 1", 80, HorizontalAlignment.Left);
            listView1.Columns.Add("SubItem 2", -2, HorizontalAlignment.Center);
            listView1.View = View.Details;
            listView1.FullRowSelect = true;

            //create a new instance of a list<T>:
            list = new List<MyClass>();

            //populate list<T>:
            AddingRows();

            //populating listView:
            ShowDataInListView();

            //creating comobBox`s event:
            this.comboBox1.SelectedIndexChanged += new EventHandler(comboBox1_SelectedIndexChanged);
        }

        private void AddingRows()
        {
            //some example population wtih 6 letters:
            string letters = "ABACADC";
            for (int i = 0; i < letters.Length; i++)
            {
                if (!comboBox1.Items.Contains(letters[i].ToString()))
                    comboBox1.Items.Add(letters[i].ToString());
                MyClass mc = new MyClass();
                mc.Item = "Item " + (i + 1);
                mc.SubItem1 = "SubItem " + (i + 1);
                mc.SubItem2 = letters[i].ToString();
                list.Add(mc);
            }
        }

        private void ShowDataInListView()
        {
            foreach (MyClass mc in list)
            {
                ListViewItem lvi = new ListViewItem(mc.Item);
                lvi.SubItems.Add(mc.SubItem1);
                lvi.SubItems.Add(mc.SubItem2);
                listView1.Items.Add(lvi);
            }
        }

        private void comboBox1_SelectedIndexChanged(object sender, EventArgs e)
        {
            string comboSelection = (string)comboBox1.SelectedItem;
            listView1.Items.Clear();
            foreach (MyClass mc in list)
            {
                if (comboSelection == mc.SubItem2)
                {
                    ListViewItem lvi = new ListViewItem(mc.Item);
                    lvi.SubItems.Add(mc.SubItem1);
                    lvi.SubItems.Add(mc.SubItem2);
                    listView1.Items.Add(lvi);
                }
            }
        }
    }

    class MyClass
    {
        public string Item { get; set; }
        public string SubItem1 { get; set; }
        public string SubItem2 { get; set; }
    }
}

Will add some code to add and remove the items...
Mitja Bonca 557 Nearly a Posting Maven

Would you mind showing me an example? I have no clue about what you are talking about.
What subItems in comboBox? There is no subItems in comboBox.
I need an example code, with items and subItems.

Mitja Bonca 557 Nearly a Posting Maven

when ever i choose an item from the comboBox the listView will show only the items that there's subItem have the same text of the ComboBoxItem

Would you explain this a bit better? I dont have an idea of what you thing? Simply...

Mitja Bonca 557 Nearly a Posting Maven

From where do you get data?

Mitja Bonca 557 Nearly a Posting Maven

If you do:

dataGridView1[7,a].Value = "Some Value";

if all the conditions:
- 8th column at index 7 exists
- row and index a (some integer) exists

The value = "Some text" HAS TO write into that cell. There is no other way.

One more question: How do you create your dataGridView?
If there is only a text in 8th column, you actually dont need to create it.
You can only do:

dataGridView1.Columns.Add("column8", "Acutal column name");