Exemplo n.º 1
0
        private void btAdd_Click(object sender, EventArgs e)
        {
            if (syntaxTextBox.Text != "")
            {
                HighLightList.SuspendLayout();

                DataGridViewRow dataGridViewRow = new DataGridViewRow();
                dataGridViewRow.CreateCells(HighLightList);
                dataGridViewRow.Cells[0].Value = true;

                dataGridViewRow.Cells[1].Value = syntaxTextBox.Text;
                //dataGridViewRow.Cells[1].Style.BackColor = syntaxSample.BackColor;
                //dataGridViewRow.Cells[1].Style.ForeColor = syntaxSample.ForeColor;
                //dataGridViewRow.Cells[1].Style.Font = new Font(syntaxSample.Font.FontFamily, syntaxSample.Font.Size, syntaxSample.Font.Style);

                dataGridViewRow.Cells[2].Value           = "sample";
                dataGridViewRow.Cells[2].Style.BackColor = syntaxSample.BackColor;
                dataGridViewRow.Cells[2].Style.ForeColor = syntaxSample.ForeColor;
                dataGridViewRow.Cells[2].Style.Font      = syntaxSample.Font;

                HighLightList.Rows.Add(dataGridViewRow);

                dataGridViewRow.Selected = true;

                HighLightList.ResumeLayout();
            }
        }
Exemplo n.º 2
0
        /*private void SaveToXml(string file)
         * {
         *  try
         *  {
         *      XmlDocument doc = new XmlDocument();
         *      XmlDeclaration dec = doc.CreateXmlDeclaration("1.0", "utf-8", null);
         *      doc.AppendChild(dec);
         *
         *      XmlElement root = doc.CreateElement("cmdlist");
         *      doc.AppendChild(root);
         *      foreach (DataGridViewRow row in metroGrid.Rows)
         *      {
         *          XmlElement element = doc.CreateElement("CMD");
         *          element.SetAttribute("cmd", (string)row.Cells["ColumnCmd"].Value);
         *          element.SetAttribute("discription", (string)row.Cells["ColumnDiscription"].Value);
         *          root.AppendChild(element);
         *      }
         *
         *      doc.Save(@file);
         *  }
         *  catch (Exception ex)
         *  {
         *      MessageBox.Show(this, ex.Message, "MetroMessagebox");
         *  }
         * }*/

        public void AddRow(string syntax, Color fore, Color back, FontStyle style)
        {
            if (syntax != "")
            {
                HighLightList.SuspendLayout();

                DataGridViewRow dataGridViewRow = new DataGridViewRow();
                dataGridViewRow.CreateCells(HighLightList);
                dataGridViewRow.Cells[0].Value           = true;
                dataGridViewRow.Cells[1].Value           = syntax;
                dataGridViewRow.Cells[2].Value           = "sample";
                dataGridViewRow.Cells[2].Style.BackColor = back;
                dataGridViewRow.Cells[2].Style.ForeColor = fore;
                dataGridViewRow.Cells[2].Style.Font      = new Font("SimSun", 10f, style);

                HighLightList.Rows.Add(dataGridViewRow);

                dataGridViewRow.Selected = true;

                HighLightList.ResumeLayout();
            }
        }
Exemplo n.º 3
0
        private void btModify_Click(object sender, EventArgs e)
        {
            foreach (DataGridViewRow row in HighLightList.SelectedRows)
            {
                HighLightList.SuspendLayout();

                if (syntaxTextBox.Text != "")
                {
                    row.Cells[1].Value           = syntaxTextBox.Text;
                    row.Cells[2].Style.BackColor = syntaxSample.BackColor;
                    row.Cells[2].Style.ForeColor = syntaxSample.ForeColor;
                    row.Cells[2].Style.Font      = syntaxSample.Font;
                }
                else
                {
                    //
                }

                HighLightList.ResumeLayout();

                return;
            }
        }