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.

How to get a cell's value during RowsInserting event

Thread ID:

Created:

Updated:

Platform:

Replies:

6161 Aug 2,2003 11:55 AM Aug 2,2003 03:13 PM Windows Forms 1
loading
Tags: GridControl
ERobishaw
Asked On August 2, 2003 11:55 AM

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 03:13 PM

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.

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.

;