Ejemplo n.º 1
0
 private void PropertyForm_FormClosing(object sender, FormClosingEventArgs e)
 {
     if (this.bool_0 && (MessageBoxHelper.Show("属性已修改,是否把修改后的样式永久保存到本地?\n", "数据保存提示", MessageBoxButtons.YesNo, MessageBoxIcon.Asterisk, MessageBoxDefaultButton.Button1) == DialogResult.Yes))
     {
         XmlComponentUtil.SaveDataGridViewStyles(this.string_0, this.dataGridView_0, this.string_1, this.string_2);
     }
 }
Ejemplo n.º 2
0
        public void LoadGridStyles(XmlNode xmlNode_0)
        {
            XmlAttributeCollection attributes = xmlNode_0.Attributes;
            string text1 = attributes["id"].Value;
            string text2 = attributes["control.type"].Value;

            XmlComponentUtil.SetDataGridProperty(attributes, this.customStyleDataGrid1);
            SortedList <int, DataGridViewColumn> list = new SortedList <int, DataGridViewColumn>();

            this.AutoGenerateColumns = false;
            if (xmlNode_0.HasChildNodes)
            {
                foreach (XmlNode node in xmlNode_0)
                {
                    if ("DataGridViewColumnCollection".Equals(node.Name))
                    {
                        if (node.HasChildNodes)
                        {
                            foreach (XmlNode node2 in node)
                            {
                                if ("DataGridViewColumnItem".Equals(node2.Name))
                                {
                                    DataGridViewColumn dataGridViewColumnItem = XmlComponentUtil.GetDataGridViewColumnItem(node2, this.customStyleDataGrid1);
                                    if ((dataGridViewColumnItem != null) && !this.Columns.Contains(dataGridViewColumnItem.Name))
                                    {
                                        list.Add(dataGridViewColumnItem.DisplayIndex, dataGridViewColumnItem);
                                    }
                                }
                            }
                            if ((list != null) && (list.Count > 0))
                            {
                                foreach (int num in list.Keys)
                                {
                                    this.customStyleDataGrid1.Columns.Add(list[num]);
                                }
                            }
                        }
                    }
                    else
                    {
                        DataGridViewCellStyle dataGridCellStyle = XmlComponentUtil.GetDataGridCellStyle(node, this.customStyleDataGrid1);
                        if (dataGridCellStyle != null)
                        {
                            PropertyInfo property = this.customStyleDataGrid1.GetType().GetProperty(node.Name);
                            if (property != null)
                            {
                                property.SetValue(this.customStyleDataGrid1, dataGridCellStyle, null);
                            }
                        }
                    }
                }
            }
        }