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.
Unfortunately, activation email could not send to your email. Please try again.

Edit a row in grid

Thread ID:

Created:

Updated:

Platform:

Replies:

103079 Mar 28,2012 12:50 PM Apr 10,2012 02:40 AM ASP.NET Web Forms (Classic) 6
loading
Tags: GridGroupingControl
Smitha
Asked On March 28, 2012 12:50 PM

Hi,

Can someone help me the events req to edit, update a row in the grid control.

When the user selects a edit from the context menu, the rows should be editable

SMitha


Sridhar N [Syncfusion]
Replied On March 29, 2012 07:57 AM

Hi Smitha,

Thanks for your interest in Syncfusion products.

Query #1 “Can someone help me the events req to edit, update a row in the grid control.”

Considering your requirement is about GridGroupingControl, we provide the solution. Your requirement to edit the grid and to hook corresponding event is “DataSourceControlRowUpdating”. Please refer the below code snippet.

[Codebehind – C#]
protected void Page_Load(object sender, EventArgs e)
{
// Event Hook
this.GridGroupingControl1.DataSourceControlRowUpdating += new Syncfusion.Web.UI.WebControls.Grid.Grouping.GridDataSourceControlRowUpdateEventHandler(GridGroupingControl1_DataSourceControlRowUpdating);
}

//Event handler
void GridGroupingControl1_DataSourceControlRowUpdating(object sender, Syncfusion.Web.UI.WebControls.Grid.Grouping.GridDataSourceControlRowUpdateEventArgs e)
{
e.Cancel = true;
e.Handled = true;
}

For your convenience, we have created sample and the same can be downloaded from the following link.

http://www.syncfusion.com/downloads/Support/DirectTrac/General/Editing1403998039.zip

Please refer the below link for online sample.
http://asp.syncfusion.com/demos/ui/gridgrouping/CRUD%20Operations/EditCellTypes/cs/EditCellType.aspx

Please let us know if any concerns.

Regards,
Sridhar N





Smitha
Replied On April 1, 2012 09:45 PM

Hi Sridhar,

Thank you for the solution. But I am not using the grid grouping control,
I am using the grid control. This is achieve excel like functionality. The user can add cells, delete cells, add rows, delete rows, edit rows, select rows

Here's how far I got.
On selecting a cell and right click, the user should be able to add cells. I was able to a context menu for the right click.
But for adding cells functionality, I am not sure how to get the rowindex, colindex of the selected cell.
None of these seem to get the row/colindex
//int currentMouseOverColumn1 = theGrid.GridCellsRange.Left;
//int currentMouseOverRow1 = theGrid.GridCellsRange.Right;
// int currentMouseOverRow = theGrid.CurrentCell.RowIndex;
// int currentMouseOverColumn = theGrid.CurrentCell.ColIndex;

Also, when the user selects a cell, I want the cell to be hightlighted just like in excel.

Any help is appreciated.

Thanks
Smitha




Smitha
Replied On April 1, 2012 09:47 PM

Also, the online sample link doesnt seem to be working. It is giving me a runtime, web.config error


Mercy C [Syncfusion]
Replied On April 5, 2012 08:09 AM

Hi Smitha,

Thanks for your interest in syncfusion products.

Please do let us know which platform you are using either Windows or Web so that we can provide solution accordingly.

Please do let me know if you have any concerns.

Regards,
Mercy.C


Smitha
Replied On April 5, 2012 12:20 PM

Hi Mercy,

I am using windows forms+ grid control, C#

Smitha




Mercy C [Syncfusion]
Replied On April 10, 2012 02:40 AM

Hi Smitha,

Thanks for your update.

Query 1: You can make use of "CurrentCellStartEditing" event to edit a cell.

Query2: You can insert, delete the rows using "InsertRange()" and "DeleteRange()" methods which is handled in "contextMenuStrip1_ItemClicked" event.

void contextMenuStrip1_ItemClicked(object sender, ToolStripItemClickedEventArgs e)
{
row = 0;
col = 0;
this.gridControl1.PointToRowCol(p,out row, out col);
if (e.ClickedItem.ToString() == "Insert")
{
this.gridControl1.Rows.InsertRange(row, 1); //inserts 1 row before selected row
}

if (e.ClickedItem.ToString() == "Delete")
{
this.gridControl1.Rows.RemoveRange(row, row);// deletes the selected row
}
}

Query3 : To Select rows, you can set "AllowSelection" flag to "Row". "AlphaBlendSelectionColor" gives the specified color to the selected row.

this.gridControl1.AllowSelection = Syncfusion.Windows.Forms.Grid.GridSelectionFlags.Row | Syncfusion.Windows.Forms.Grid.GridSelectionFlags.AlphaBlend;
this.gridControl1.AlphaBlendSelectionColor = Color.Blue;

Query 4: To insert cells and delete cells, we dont have support.

Query 5: To highlight the borders of selected cells, please make use of "CellClick" and "CurrentCellControlLostFocus" events. Set the required border style in "CellClick" event and reset the border in "CurrentCellControlLostFocus" event.

void gridControl1_CellClick(object sender, Syncfusion.Windows.Forms.Grid.GridCellClickEventArgs e)
{
style = this.gridControl1[e.RowIndex, e.ColIndex];
style.Borders.All = new GridBorder(GridBorderStyle.Solid, Color.Black, GridBorderWeight.ExtraThin);

if (e.RowIndex >= 1 && e.MouseEventArgs.Button == MouseButtons.Right)
{
this.contextMenuStrip1.Show(this.gridControl1, e.MouseEventArgs.Location);
p = e.MouseEventArgs.Location;
}
}

void gridControl1_CurrentCellControlLostFocus(object sender, ControlEventArgs e)
{
style.Borders.All = new GridBorder(GridBorderStyle.Standard);
}


Please refer to the sample in the following link
http://www.syncfusion.com/downloads/Support/DirectTrac/93095/WindowsFormsApplication811573917874.zip

Please let me know if you have any concerns.

Regards,
Mercy.C


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.

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.

;