Exemplo n.º 1
0
        /// <summary>
        /// 绑定所有的群组
        /// </summary>
        private void BindGroups()
        {
            m_gridGroups.UseAnimation = true;
            List <GridRow> rows     = m_gridGroups.m_rows;
            int            rowsSize = rows.Count;

            for (int i = 0; i < rowsSize; i++)
            {
                GridRow row = rows[i];
                if (row.EditButton != null)
                {
                    m_gridGroups.RemoveControl(row.EditButton);
                    row.EditButton = null;
                }
                m_gridGroups.RemoveRow(row);
                i--;
                rowsSize--;
            }
            m_gridGroups.Update();
            GridRow firstRow = new GridRow();

            m_gridGroups.AddRow(firstRow);
            GridStringCell cell1 = new GridStringCell("");

            firstRow.AddCell("colG1", cell1);
            GridStringCell cell2 = new GridStringCell("全部");

            firstRow.AddCell("colG2", cell2);
            GridStringCell cell3 = new GridStringCell("");

            firstRow.AddCell("colG3", cell3);
            int groupsSize = m_chatGroups.Count;

            for (int i = 0; i < groupsSize; i++)
            {
                ChatGroup chatGroup = m_chatGroups[i];
                GridRow   cRow      = new GridRow();
                m_gridGroups.AddRow(cRow);
                ButtonA deleteButton = new ButtonA();
                deleteButton.Height    = cRow.Height;
                deleteButton.Name      = "btnDelete";
                deleteButton.Tag       = chatGroup.Name;
                deleteButton.BackColor = COLOR.ARGB(255, 0, 0);
                deleteButton.Native    = m_gridHosts.Native;
                deleteButton.Text      = "删除";
                cRow.EditButton        = deleteButton;
                cRow.AllowEdit         = true;
                GridStringCell cCell1 = new GridStringCell(chatGroup.Name);
                cRow.AddCell("colG1", cCell1);
                GridStringCell cCell2 = new GridStringCell(chatGroup.DisplayName);
                cRow.AddCell("colG2", cCell2);
                String strIDs      = "";
                int    userIDsSize = chatGroup.UserIDs.Count;
                for (int j = 0; j < userIDsSize; j++)
                {
                    strIDs += chatGroup.UserIDs[j];
                    if (j != userIDsSize - 1)
                    {
                        strIDs += ",";
                    }
                }
                GridStringCell cCell3 = new GridStringCell(strIDs);
                cRow.AddCell("colG3", cCell3);

                ControlMouseEvent clickButtonEvent = new ControlMouseEvent(ClickEvent);
                deleteButton.RegisterEvent(clickButtonEvent, EVENTID.CLICK);
            }
            m_gridGroups.Update();
            m_gridGroups.Invalidate();
        }