Exemplo n.º 1
0
        private void fromTableToText()
        {
            TextTableProcessor processor = new TextTableProcessor(editor.Text, textBox.Text);
            IRelation          relation  = new DefaultRelation();

            String[] columns = new String[dataGrid.Columns.Count];
            for (int i = 0; i < dataGrid.Columns.Count; i++)
            {
                columns[i] = dataGrid.Columns[i].HeaderText;
            }
            String[][] data = new String[dataGrid.Rows.Count][];

            for (int i = 0; i < dataGrid.Rows.Count; i++)
            {
                String[] row = new String[columns.Length];
                for (int j = 0; j < columns.Length; j++)
                {
                    object cell_value = dataGrid.Rows[i].Cells[j].Value;
                    row[j] = cell_value != null?cell_value.ToString() : "";
                }
                data[i] = row;
            }
            relation.setData(data);
            relation.setColumns(columns);

            textBox.Text             = processor.process(relation);
            tabControl.SelectedIndex = 0;
        }
Exemplo n.º 2
0
        private void fromTextToTable()
        {
            String             scriptText = editor.Text;
            String             text       = textBox.Text;
            TextTableProcessor processor  = new TextTableProcessor(scriptText, text);
            IRelation          relation   = processor.process();

            dataGrid.Rows.Clear();
            dataGrid.RowCount = 0;
            dataGrid.Columns.Clear();
            foreach (String column in relation.getColumns())
            {
                dataGrid.Columns.Add(column, column);
            }
            for (int i = 0; i < relation.getData().Length; i++)
            {
                String[] row = relation.getData()[i];
                dataGrid.Rows.Add(row);
            }
            tabControl.SelectedIndex = 2;
        }