Пример #1
0
 private void btnQuestionMark_Click(object sender, EventArgs e)
 {
     for (int i = 0; i < dataGridView.Rows.Count; i++)
     {
         ((DataGridViewComboBoxCell)dataGridView[(int)Column.CurrentOptionColumnIndex, i]).Value = "???";
         ((DataGridViewTextBoxCell)dataGridView[(int)Column.ValueColumnIndex, i]).Value          = "0";
     }
     txtBoxBits.Text = "0";
     BitButtons.RefreshAll();
     SetColorsInDataGridView();
 }
Пример #2
0
        void dataGridView_OnTextChanged(object sender, DataGridViewCellEventArgs e)
        {
            if (e.ColumnIndex == (int)Column.CurrentOptionColumnIndex || e.ColumnIndex == (int)Column.ValueColumnIndex)
            {
                DataGridViewCell cell = dataGridView[e.ColumnIndex, e.RowIndex];
                int bitID;
                try
                {
                    bitID = int.Parse(dataGridView.Rows[cell.RowIndex].Cells[(int)Column.IDColumnIndex].Value.ToString());
                }
                catch
                {
                    return;
                }
                BitGroup flag = selectedFlagList.flags[bitID];
                if ((Column)e.ColumnIndex == Column.ValueColumnIndex)
                {
                    try
                    {
                        cell.Value = CommonUtils.Clamp(int.Parse(cell.Value.ToString()), 0, flag.GetMaxSize());
                    }
                    catch
                    {
                        cell.Value = 0;
                    }
                }
                int i32 = GetValueFromTextBox();
                txtBoxBits.Text = GetFlagIntWithModifedFlagFromCell(cell, i32, flag).ToString();
                txtBoxBits.Refresh();

                if (e.ColumnIndex == (int)Column.CurrentOptionColumnIndex)
                {
                    RefreshValueInDataGridView(e.RowIndex);
                }
                if (e.ColumnIndex == (int)Column.ValueColumnIndex)
                {
                    RefreshCurrentOptionInDataGridView(e.RowIndex);
                }

                BitButtons.RefreshAll();
                SetColorsInDataGridView();
            }
        }
Пример #3
0
        public void RefreshDataGridView()
        {
            if (selectedFlagList == null)
            {
                return;
            }

            int value = GetValueFromTextBox();
            List <ParsedFlagData> flagDataList = selectedFlagList.Parse(value);

            dataGridView.Rows.Clear();
            dataGridView.Columns[0].ReadOnly = true;
            dataGridView.Columns[1].ReadOnly = true;
            dataGridView.Columns[2].ReadOnly = true;


            for (int i = 0; i < flagDataList.Count; i++)
            {
                int row = dataGridView.Rows.Add(flagDataList[i].bitNumber, flagDataList[i].bitSize, flagDataList[i].description, flagDataList[i].currentOption, flagDataList[i].value);

                dataGridView.Rows[i].Cells[3].Value = null; //this is important.
                DataGridViewComboBoxCell c = new DataGridViewComboBoxCell();

                foreach (KeyValuePair <string, int> kv in flagDataList[i].options)
                {
                    c.Items.Add(kv.Key);
                }

                c.Value     = flagDataList[i].currentOption;
                c.FlatStyle = FlatStyle.Flat;
                dataGridView.Rows[i].Cells[(int)Column.CurrentOptionColumnIndex] = c;
                dataGridView.Rows[i].Height = 25;
            }
            BitButtons.RefreshAll();
            SetColorsInDataGridView();
        }