Exemple #1
0
        /// <summary>
        /// Xóa client ra khỏi listview
        /// </summary>
        /// <param name="client"></param>
        public void removeClientFromListView(MyClient client)
        {
            MyClient my_new_text = client;

            // InvokeRequired required compares the thread ID of the
            // calling thread to the thread ID of the creating thread.
            // If these threads are different, it returns true.
            if (this.tbMessage.InvokeRequired)
            {
                SetLvClientCallback d = new SetLvClientCallback(removeClientFromListView);
                this.Invoke(d, new object[] { client });
            }
            else
            {
                for (int i = 0; i < lvClients.Items.Count; i++)
                {
                    int id = (int)lvClients.Items[i].Tag;

                    if (id == client.getId())
                    {
                        lvClients.Items.RemoveAt(i);
                        break;
                    }
                }
            }
        }
Exemple #2
0
        /// <summary>
        /// Thêm một client vào danh sách user
        /// </summary>
        /// <param name="client"></param>
        /// <returns></returns>
        public void addClientToListView(MyClient client)
        {
            //ListViewItem item = new ListViewItem();
            //item.Text = client.Username;
            //item.Tag = client.getId();
            //item.SubItems.Add("");

            //lvClients.Items.Add(item);

            MyClient my_new_text = client;
            // InvokeRequired required compares the thread ID of the
            // calling thread to the thread ID of the creating thread.
            // If these threads are different, it returns true.
            if (this.tbMessage.InvokeRequired)
            {
                SetLvClientCallback d = new SetLvClientCallback(addClientToListView);
                this.Invoke(d, new object[] { client });
            }
            else
            {
                ListViewItem item = new ListViewItem();
                item.Text = client.Username;
                item.Tag = client.getId();
                item.SubItems.Add("");

                lvClients.Items.Add(item);
            }
        }
Exemple #3
0
        /// <summary>
        /// Thêm một client vào danh sách user
        /// </summary>
        /// <param name="client"></param>
        /// <returns></returns>
        public void addClientToListView(MyClient client)
        {
            //ListViewItem item = new ListViewItem();
            //item.Text = client.Username;
            //item.Tag = client.getId();
            //item.SubItems.Add("");

            //lvClients.Items.Add(item);

            MyClient my_new_text = client;

            // InvokeRequired required compares the thread ID of the
            // calling thread to the thread ID of the creating thread.
            // If these threads are different, it returns true.
            if (this.tbMessage.InvokeRequired)
            {
                SetLvClientCallback d = new SetLvClientCallback(addClientToListView);
                this.Invoke(d, new object[] { client });
            }
            else
            {
                ListViewItem item = new ListViewItem();
                item.Text = client.Username;
                item.Tag  = client.getId();
                item.SubItems.Add("");

                lvClients.Items.Add(item);
            }
        }
Exemple #4
0
        /// <summary>
        /// Xóa client ra khỏi listview
        /// </summary>
        /// <param name="client"></param>
        public void removeClientFromListView(MyClient client)
        {
            MyClient my_new_text = client;
            // InvokeRequired required compares the thread ID of the
            // calling thread to the thread ID of the creating thread.
            // If these threads are different, it returns true.
            if (this.tbMessage.InvokeRequired)
            {
                SetLvClientCallback d = new SetLvClientCallback(removeClientFromListView);
                this.Invoke(d, new object[] { client });
            }
            else
            {
                for (int i = 0; i < lvClients.Items.Count; i++)
                {
                    int id = (int)lvClients.Items[i].Tag;

                    if (id == client.getId())
                    {
                        lvClients.Items.RemoveAt(i);
                        break;
                    }
                }
            }
        }