Thread ID: |
Created: |
Updated: |
Platform: |
Replies: |
140905 | Nov 13,2018 03:30 PM UTC | Nov 14,2018 06:33 AM UTC | WinForms | 1 |
![]() |
Tags: GridControl |
this.gridControl1.CellDoubleClick += GridControl1_CellDoubleClick;
MetroForm form;
private void GridControl1_CellDoubleClick(object sender, GridCellClickEventArgs e)
{
int Columncount = this.gridControl1.ColCount;
Label[] label = new Label[Columncount];
TextBox[] textbox = new TextBox[Columncount];
Button button = new Button();
Button button2 = new Button();
if (!this.gridControl1.ReadOnly && !this.gridControl1.BrowseOnly)
{
f = new MetroForm();
for (int i = 0; i < Columncount; i++)
{
//Label initialization
label[i] = new Label();
label[i].Text = this.gridControl1[0, i + 1].Text;
label[i].Location = new Point(10, i * 30);
label[i].Size = new Size(80, 20);
f.Controls.Add(label[i]);
GridStyleInfo style = this.gridControl1[e.RowIndex, i + 1];
if (style.CellType == GridCellTypeName.MonthCalendar)
{
DateTimePicker calendar = new DateTimePicker();
calendar.Location = new Point(label[i].Right + 10, i * 30);
calendar.Value = (Convert.ToDateTime(this.gridControl1[e.RowIndex, i + 1].CellValue));
calendar.Size = new System.Drawing.Size(100, 13);
calendar.Tag = label[i];
calendar.LostFocus += Form1_TextChanged;
f.Controls.Add(calendar);
}
else
{
//Text box initialization
textbox[i] = new TextBox();
textbox[i].Location = new Point(90, i * 30);
textbox[i].Text = this.gridControl1[e.RowIndex, i + 1].Text;
textbox[i].LostFocus += Form1_TextChanged;
textbox[i].Tag = label[i];
f.Controls.Add(textbox[i]);
}
}
button.Location = new Point(72, 200);
button.Size = new System.Drawing.Size(75, 23);
button.Text = "Ok";
button.Click += Form1_Click;
button2.Location = new Point(button.Right + 5, button.Location.Y);
button2.Size = button.Size;
button2.Text = "Cancel";
button2.Click += Button2_Click;
f.Controls.Add(button);
f.Controls.Add(button2);
f.Text = "Details of Record";
f.ShowIcon = false;
f.MaximizeBox = false;
f.MinimizeBox = false;
f.FormBorderStyle = System.Windows.Forms.FormBorderStyle.FixedDialog;
f.ShowDialog();
}
} |
This post will be permanently deleted. Are you sure you want to continue?
Sorry, An error occured while processing your request. Please try again later.
This page will automatically be redirected to the sign-in page in 10 seconds.