/// <summary> /// Also GridView-ban ralepunk egy cellara. Ha nem ReadOnly, a cella lesz az altiv cella. Ha az inputcella /// combo jellegu, a ComboBoxunkat rahelyezzuk a cellara, beallitjuk a ComboBox valasztekot, a ComboBox /// select indexet a cella tartalma alapjan /// </summary> /// <param name="sender"></param> /// <param name="e"></param> public virtual void dataGridView2_CellClick(object sender, DataGridViewCellEventArgs e) { if (!FakUserInterface.EventTilt && e.ColumnIndex!= 0 && !dataGridView2.ReadOnly && !dataGridView2.CurrentCell.ReadOnly && !Inputtabla.Columns[1].ReadOnly) { aktivcell = dataGridView2.CurrentCell; Size cellsize = aktivcell.Size; DataGridViewCell dc = aktivcell; if (dc != null && dc.ReadOnly != true) { aktivcol = InputColumns[dc.RowIndex]; string tartal = dc.Value.ToString().Trim(); c = dataGridView2.GetColumnDisplayRectangle(dc.ColumnIndex, true); x = dataGridView2.GetRowDisplayRectangle(dc.RowIndex, true); dataGridView2.Controls.Remove(comboBox1); comboBox1.Visible = false; combocell = null; comboBox1.Text = ""; comboBox1.Tag = null; dc.Value = tartal; if (aktivcol.Comboe) { combocell = dc; if (aktivcol.Combo_Info != null) { if (aktivcol.ReadOnly) { tartal = ""; dc.Value = ""; return; } aktivcol.ComboAktFileba = aktivcol.Combo_Info.GetComboAktfileba(tartal); } dataGridView2.Controls.Add(comboBox1); if (kezeloidcol != null && kezelotag != null && aktivcol.ColumnName==kezeloidcol.ColumnName) { comboBox1.Tag = kezelotag; comboBox1.Items.Clear(); string[] kezeloidk = FakUserInterface.GetSzurtOsszefIdk(kezalkinfo.Osszefinfo, new object[] { "", FakUserInterface.AlkalmazasId }); if (kezeloidk != null) { for (int i = 0; i < kezeloidk.Length; i++) { int j = aktivcol.Combo_Info.ComboFileinfo.IndexOf(kezeloidk[i]); comboBox1.Items.Add(aktivcol.Combo_Info.ComboInfo[j].ToString()); } } } //if (cegalktag != null) // comboBox1.Tag = cegalktag; if (aktivcol.ColumnName == "TABLANEV" && tablanevtag!=null) { comboBox1.Tag = tablanevtag; comboBox1.Items.Clear(); for (int i = 0; i < comboitems.Count; i++) comboBox1.Items.Add(comboitems[i]); } else if (aktivcol.ColumnName == "SZULOSZINT" && Tabinfo.Tablanev == "TABLANEVEK") { comboBox1.Items.Clear(); comboBox1.Items.AddRange(aktivcol.Combo_Info.ComboSzovinfoAll()); comboBox1.Items.Insert(0, ""); if (tartal == "") comboBox1.SelectedIndex = 0; else comboBox1.SelectedIndex = aktivcol.Combo_Info.ComboInfo.IndexOf(tartal); } else if (aktivcol.ColumnName == "SZULOTABLA" || aktivcol.ColumnName == "FEJTABLA" || aktivcol.ColumnName == "LABTABLA") { comboBox1.Items.Clear(); string szulotablaszint = ""; string tablanev = ""; adatszolg = Tabinfo.Tablanev == "USERADATSZOLG"; if (!adatszolg) szulotablaszint = InputColumns["SZULOSZINT"].ComboAktFileba; if (szulotablaszint != "" || adatszolg) tablanev = Inputtabla.Rows[Tabinfo.InputColumns.IndexOf("SZOVEG")][1].ToString(); if (tablanev != "") { comboBox1.Tag = szulotablatag; if (!adatszolg) Tabinfo.DataView.RowFilter = "SZINT='" + szulotablaszint + "' and SZOVEG<>'" + tablanev + "'"; else Tabinfo.DataView.RowFilter = "SZOVEG<>'" + tablanev + "'"; if (Tabinfo.DataView.Count != 0) { ArrayList idarray = new ArrayList(); for (int i = 0; i < Tabinfo.DataView.Count; i++) { DataRow dr = Tabinfo.DataView[i].Row; idarray.Add(dr["SZOVEG"].ToString()); } string[] idk = (string[])idarray.ToArray(typeof(string)); FakUserInterface.Comboinfoszures(comboBox1, idk); } Tabinfo.DataView.RowFilter = ""; } else { tablanev = Inputtabla.Rows[Tabinfo.InputColumns.IndexOf("SZULOTABLA")][1].ToString(); } } else if (aktivcol == kezeloidcol) { } else if (comboBox1.Tag == null) { if (aktivcol.Combo_Info == null) aktivcol.ComboAzontipCombo.SetComboItems(comboBox1, aktivcol, tartal); else aktivcol.Combo_Info.SetComboItems(comboBox1, aktivcol, tartal); } comboBox1.TabIndex = dataGridView2.TabIndex; comboBox1.Bounds = c; comboBox1.Size = cellsize; comboBox1.Location = new System.Drawing.Point(comboBox1.Location.X + x.Location.X, comboBox1.Location.Y + x.Location.Y + dataGridView2.Location.Y); comboBox1.Visible = true; FakUserInterface.ErrorProvider.SetError(comboBox1, hibaszov[aktivcell.RowIndex]); combovisible = true; } else { if (aktivcol.Numeric(aktivcol.DataType)) dc.Style.ApplyStyle(tempcellnum.Style); else dc.Style.ApplyStyle(tempcellstr.Style); } } } else aktivcol = null; }
/// <summary> /// TextColumn letrehozasa a DataGridView-hoz /// </summary> /// <param name="egycol"> /// mezoinformacio objectum /// </param> /// <param name="Readonly"> /// true: a Column ReadOnly /// </param> /// <returns></returns> public DataGridViewColumn Ujtextcolumn(Cols egycol, bool Readonly) { DataGridViewTextBoxColumn textcol = new DataGridViewTextBoxColumn(); textcol.DataPropertyName = egycol.ColumnName; textcol.Name = egycol.ColumnName; textcol.HeaderText = egycol.Caption; if (egycol.ToolTip != "") textcol.ToolTipText = egycol.ToolTip; else if (egycol.Sorszov != "") textcol.ToolTipText = egycol.Sorszov; else textcol.ToolTipText = egycol.Caption; int i = egycol.Caption.Length; int j = egycol.InputMaxLength; if (i < j) i = j; if (i > 20) i = 20; textcol.MinimumWidth = egycol.Caption.Length * 9; textcol.Width = i * 9; textcol.ReadOnly = Readonly; textcol.SortMode = DataGridViewColumnSortMode.NotSortable; textcol.DefaultCellStyle = new DataGridViewCellStyle(); if (egycol.Numeric(egycol.DataType)) { textcol.DefaultCellStyle.Alignment = DataGridViewContentAlignment.MiddleRight; textcol.DefaultCellStyle.BackColor = _fak.InaktivInputBackColor; textcol.DefaultCellStyle.Font = _fak.InaktivInputFont; if (egycol.Format != "") textcol.DefaultCellStyle.Format = egycol.Format; } else { textcol.DefaultCellStyle.Alignment = DataGridViewContentAlignment.MiddleLeft; textcol.DefaultCellStyle.BackColor = _fak.InaktivInputBackColor; textcol.DefaultCellStyle.Font = _fak.InaktivInputFont; } return (DataGridViewColumn)textcol; }