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

Add, edit, delete

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

Thanks



1 Reply

AA Arulraj A Syncfusion Team 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,  

C# 
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(); 
    } 
} 


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


Loader.
Live Chat Icon For mobile
Up arrow icon