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.

Ways to get GGC data contents per cell, per data or as a row

Thread ID:

Created:

Updated:

Platform:

Replies:

56791 Feb 20,2007 07:51 PM Feb 22,2007 03:25 AM Windows Forms 7
loading
Tags: GridControl
Administrator [Syncfusion]
Asked On February 20, 2007 07:51 PM

Hello,
How can I access data in a ggc outside of an event handler? I the following code,

ggc_TableControlCellClick(object sender, GridTableControlCellClickEventArgs e)

I can do things like

GridCurrentCell cc = e.TableControl.CurrentCell;
int rowIndex = cc.RowIndex;
int colIndex = cc.ColIndex;

etc. to get at the data. What if I don't have
GridTableControlCellClickEventArgs and just

this.ggc.TableControl... etc.

inside a method?

What are my options for accessing the grid, from the GGC object down to the individual cells?

Thanks,
Dimitri

Administrator [Syncfusion]
Replied On February 21, 2007 01:21 PM

First comment is that using row and column indexes in a GridGroupingControl can be problematic when you start working with nested and grouped tables. Generally, it is better to think about accessing the underlying Record objects. One collection you can use to see the records is grid.Table.FilteredRecords. This collection should correspond to the filtered, sorted list of records being displayed in the particular table. Once you have the record, you can use record.GetValue to access particular fields in the record.

But if you want to try to use row/column indexes, then one thing you can do is to use this.gridGroupingControl1.TableControl.GetTableViewStyleInfo to get the GridtableCellStyleInfo for a particular cell. Once you have that, you can access the style.TableCellIdentity which has all the information you need to know about a cell, including the DisplayElement.

Administrator [Syncfusion]
Replied On February 21, 2007 01:38 PM

Thanks Clay, but, how do I know which row in the grid is currently selected? I can't know its index and constituent cell unless I can tell where the cursor is at a given time. Is there a way to do that?





>First comment is that using row and column indexes in a GridGroupingControl can be problematic when you start working with nested and grouped tables. Generally, it is better to think about accessing the underlying Record objects. One collection you can use to see the records is grid.Table.FilteredRecords. This collection should correspond to the filtered, sorted list of records being displayed in the particular table. Once you have the record, you can use record.GetValue to access particular fields in the record.

But if you want to try to use row/column indexes, then one thing you can do is to use this.gridGroupingControl1.TableControl.GetTableViewStyleInfo to get the GridtableCellStyleInfo for a particular cell. Once you have that, you can access the style.TableCellIdentity which has all the information you need to know about a cell, including the DisplayElement.

Administrator [Syncfusion]
Replied On February 21, 2007 01:45 PM

Here is one way.

GridCurrentCell cc = grid.TableControl.GetNestedCurrentCell();
GridTableCellStyleInfo style = grid.TableControl.GetTableViewStyleInfo(cc.RowIndex, cc.ColIndex);

Administrator [Syncfusion]
Replied On February 21, 2007 02:11 PM

Thanks Clay, that promises to be useful - but can I know what record is currenly selected, and the count of its cells, so that I can capture that record and save it?

something like: grid.activerecord.cell(i).text;

that would allow me to loop through the individual cells for that active record.



>Here is one way.

GridCurrentCell cc = grid.TableControl.GetNestedCurrentCell();
GridTableCellStyleInfo style = grid.TableControl.GetTableViewStyleInfo(cc.RowIndex, cc.ColIndex);

Administrator [Syncfusion]
Replied On February 21, 2007 06:42 PM

Try this code.

Record rec = gridGroupingControl1.Table.CurrentRecord;
if(rec != null)
object val = rec.GetValue("colName");

Administrator [Syncfusion]
Replied On February 21, 2007 09:44 PM

Thanks so much - I can use that in this case.

One other question. Whenever I click a row, in the grid on the left side, I get a highlighted row and trigger the TableControlCellClick event.
I can then see selected cells in bound text boxes.

However, if I use a GridFindReplaceDialogSink from a combobox, I'm able to find the combo display value and select the corresponding cell in the grid, but my combo boxes don't reflect the new row. How could I do this? In other words, duplicate the click event (I guess) but from a button/find method.

Thanks again,
Dimitri




>Try this code.

Record rec = gridGroupingControl1.Table.CurrentRecord;
if(rec != null)
object val = rec.GetValue("colName");

Administrator [Syncfusion]
Replied On February 22, 2007 03:25 AM

>>if I use a GridFindReplaceDialogSink from a combobox

I am not sure what this means. But if you want to make a particular record be the current record (& and see the triangle in the row header header), then try:

gridRecord.SetCurrent();

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.

;