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: June 24, 2019).
Unfortunately, activation email could not send to your email. Please try again.
Syncfusion Feedback

How to get a cell's value during RowsInserting event

Thread ID:





6161 Aug 2,2003 03:55 PM UTC Aug 2,2003 07:13 PM UTC WinForms 1
Tags: GridControl
Asked On August 2, 2003 03:55 PM UTC

I'm filling parts of a regular(non-databound) grid with datasets, via a call to PopulateValues. Works great. Now, one of the columns of data contains a boolean that tells me whether to to make 3 other cells in this row a cell-type: drop down grid. So, I'm guessing the best way to accomplish this is in the rowsInserting event? My thought is to look at the appropriate column of data in the inserted rows, for each row whose column has a text value of "true", change the cell-type to "dropdowngrid" for the 3 other columns that are supposed to be dropdowngrids. 2 Questions: 1) Is this the best approach, or is there a better way. 2) If it is, how do you actually get a the text in the RowsInserting call. Basically, I can't figure out the GridRangeInsertingEventArgs. I guess its something like: string textValue=""; for (int rowindex = 0; rowindex ++; rowindex

Administrator [Syncfusion]
Replied On August 2, 2003 07:13 PM UTC

Here is a RowsInserting event handler that shows how you can populate the cells to be inserted.
private void grid_RowsInserting(object sender, GridRangeInsertingEventArgs e)
	GridStyleInfoStoreTable data = new GridStyleInfoStoreTable(e.Count, this.gridControl1.ColCount + 1);
	for(int row = 0; row  0)
				style.BackColor = Color.LightGoldenrodYellow;
			data[row,col] = style.Store;
	e.InsertRangeOptions.Data = data;
A comment. The col loop starts at -1. The -1 entry is the style that is used to populate the RowStyle style object. As far as setting some cells (slave cells) to be dropdowngrids based on the value of another cell(master cell), there are two basic approaches. One is to deterministically set the slave cells by monitoring every time the master cell changes. You can do this in CurrentCellChanged for a checkbox cell. For other cells like a TextBox cells, you might use CurrentCellValidating or CurrentCellAcceptedChanges. The other technique is to dynamically set up the slave cells in QueryCellInfo. This event is fired whenever the grid needs a particular cell. In it, you can check e.RowIndex and e.ColIndex, and then set e.Style for this requested cell to provide the cell type. In this event, you could check the value of the master cell, and then dynamically provide the celltype based on the master cell value. I do not know one technique is beeter than another in general. If you data is dynamic, and you are already using QueryCellInfo to manage teh dynamica data, then the QueryCellInfo would be simpler in this case.


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