We use cookies to give you the best experience on our website. If you continue to browse, then you agree to our privacy policy and cookie policy. Image for the cookie policy date
Unfortunately, activation email could not send to your email. Please try again.
Syncfusion Feedback

Add, edit, delete

Thread ID:





140905 Nov 13,2018 03:30 PM UTC Nov 14,2018 06:33 AM UTC WinForms 1
Tags: GridControl
Asked On November 13, 2018 03:30 PM UTC

Do you have sample code for windows form grid similar to ASP.NET grid
https://asp.syncfusion.com/demos/web/grid/dialogonlocaldata.aspx or
using toolbar icons and search?


Arulraj A [Syncfusion]
Replied On November 14, 2018 06:33 AM UTC

Hi Arkady, 

Thanks for using Syncfusion product. 

To achieve editing in rows using Inline form, External form, Dialog form, (etc.) like ASP.NET grid in WinForms GridControl, you can create custom form based on the grid Columns which could be shown using CellDoubleClick event. Please refer to the following code example and the sample,  

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); 
            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; 
                //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]; 
        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.Text = "Details of Record"; 
        f.ShowIcon = false; 
        f.MaximizeBox = false; 
        f.MinimizeBox = false; 
        f.FormBorderStyle = System.Windows.Forms.FormBorderStyle.FixedDialog; 

Let us know whether this helps also if you need any further assistance on this. 
Arulraj A 


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.

Please sign in to access our forum

This page will automatically be redirected to the sign-in page in 10 seconds.

Warning Icon You are using an outdated version of Internet Explorer that may not display all features of this and other websites. Upgrade to Internet Explorer 8 or newer for a better experience.Close Icon

Live Chat Icon For mobile
Live Chat Icon