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. (Last updated on: November 16, 2018).
Unfortunately, activation email could not send to your email. Please try again.
Syncfusion Feedback

Add, edit, delete

Thread ID:

Created:

Updated:

Platform:

Replies:

140905 Nov 13,2018 03:30 PM UTC Nov 14,2018 06:33 AM UTC WinForms 1
loading
Tags: GridControl
arkady
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
https://asp.syncfusion.com/demos/web/grid/inlineonlocaldata.aspx
using toolbar icons and search?

Thanks



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,  

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 


CONFIRMATION

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

or the page will be automatically redirected to 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

;