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.
Syncfusion Feedback

Getting hidden cols value

Thread ID:

Created:

Updated:

Platform:

Replies:

2447 Jan 21,2003 03:01 AM UTC Jun 10,2005 04:42 AM UTC Windows Forms 6
loading
Tags: GridControl
Charles Carlin
Asked On January 21, 2003 03:01 AM UTC

If I hide a column by name grid1.Model.HideCols["id"] = true; And I have an event for double clicking on a cell (really only care about a row double click). How would I get the value for the hidden col when I know the row number and the column name?

Administrator [Syncfusion]
Replied On January 21, 2003 09:12 AM UTC

Use the GridDataBoundGrid.Binder.NameToColIndex method to get the column index from the name. Then use this column index and your row index as indexers on the grid object. int col = this.grid1.Binder.NameToColIndex("id"); string strValue = this.grid1[row, col].Text; object objValue = this.grid1[row,col].CellValue;

Ranjit
Replied On June 9, 2005 12:03 PM UTC

Clay, I am hiding Columns by calling: m_Grid.TableDescriptor.VisibleColumns.Remove("BackColor"); m_Grid.TableDescriptor.VisibleColumns.Remove("TextColor"); note: these are valid columns in my dataset I am setting the values in an Event by using the Style: GridTableCellStyleInfo style = m_Grid.TableModel[r, m_Grid.TableModel.NameToColIndex("BackColor") - 1]; style.CellValue = "1"; I am trying to Filter the records using : GridConditionalFormatDescriptor cfd_up = new GridConditionalFormatDescriptor("BackColor"); cfd_up.Expression = "[BackColor] = ''" + colorUIControl1.SelectedColor.ToArgb() + "''"; cfd_up.Appearance.AnyCell.BackColor = colorUIControl1.SelectedColor; td.ConditionalFormats.Add(cfd_up); The filter doesn''t return anything. However, if I choose not to hide these columns this code works fine. Thanks, Ranjit >Use the GridDataBoundGrid.Binder.NameToColIndex method to get the column index from the name. Then use this column index and your row index as indexers on the grid object. > > >int col = this.grid1.Binder.NameToColIndex("id"); >string strValue = this.grid1[row, col].Text; >object objValue = this.grid1[row,col].CellValue; >

Administrator [Syncfusion]
Replied On June 9, 2005 01:05 PM UTC

Whether the columns are visible or not should not make a difference whether thay can be used in a Conditional format. Here is a sample that worked for me using a hidden column. http://www.syncfusion.com/Support/user/uploads/GGC_ExpressionField_c13cb1da.zip I suspect the problem has to do with the NameToColIndex call. You should check the values in teh stayle there to make sure you are operationing on teh style you think you are. Another way to try to set teh value is to get teh GridRecord and work with it. GridRecordRow rec = style.TableCellIdentity.DisplayElement as GridRecordRow; if(rec.ParentRecord != null) rec.ParentRecord.SetValue("Col0", 10000);

Ranjit
Replied On June 9, 2005 01:24 PM UTC

Thanks your suggestion helped, but now there is a new issue. The code below, is called by an event raised by the user: *********************CODE BEGINS***************** private void HighlightRows_Clicked(object sender, EventArgs e) { GridTableDescriptor td = null; GridRangeInfo range = this.m_Grid.TableModel.Selections.Ranges.ActiveRange; if (!range.IsEmpty) { int icolInvisibleBackColor = m_Grid.TableModel.NameToColIndex("BackColor") - 1; for (int r = range.Top; r <= range.Bottom; r++) { GridTableCellStyleInfo style = m_Grid.TableModel[r, icolInvisibleBackColor]; GridRecordRow rec = style.TableCellIdentity.DisplayElement as GridRecordRow; if(rec.ParentRecord != null) rec.ParentRecord.SetValue("BackColor", colorUIControl1.SelectedColor.ToArgb().ToString()); //style.CellValue = colorUIControl1.SelectedColor.ToArgb().ToString(); //style.Text = colorUIControl1.SelectedColor.ToArgb().ToString(); } td = m_Grid.TableDescriptor; } else { GridRangeInfo inner_range = this.m_Grid.GetTableModel(m_sRelation[0]).Selections.Ranges.ActiveRange; int icolInvisibleBackColor = m_Grid.GetTableModel(m_sRelation[0]).NameToColIndex("BackColor") - 1; for (int r = inner_range.Top; r <= inner_range.Bottom; r++) { GridTableCellStyleInfo style = m_Grid.GetTableModel(m_sRelation[0])[r, icolInvisibleBackColor]; GridRecordRow rec = style.TableCellIdentity.DisplayElement as GridRecordRow; if(rec.ParentRecord != null) rec.ParentRecord.SetValue("BackColor", colorUIControl1.SelectedColor.ToArgb().ToString()); //style.CellValue = colorUIControl1.SelectedColor.ToArgb(); } td = m_Grid.GetTableDescriptor(m_sRelation[0]); } if(td != null) { GridConditionalFormatDescriptor cfd_up = new GridConditionalFormatDescriptor("BackColor"); cfd_up.Expression = "[BackColor] = ''" + colorUIControl1.SelectedColor.ToArgb() + "''"; cfd_up.Appearance.AnyCell.BackColor = colorUIControl1.SelectedColor; td.ConditionalFormats.Add(cfd_up); } } *********************CODE ENDS******************* Now, the grid used is a GGC, Steps followed are: 1. Highlight a childrow [works] 2. highlight a parent row [works] 3. Highlight a different child under the same parent row [does not work, the parent itself is getting repainted]. Thanks, Ranjit

Administrator [Syncfusion]
Replied On June 9, 2005 02:06 PM UTC

If you are trying to use this.m_Grid.TableModel.Selections.Ranges.ActiveRange, this is the selection support inherited from GridControlBase. This support does not understand nested tables, so I do not think you will be able to get this working across nested tables. Exactly what are you trying to do? Can you use the Table.SelectedRecords support? This is the record selection support specific to GridGroupingCOntrol. You turn this on by setting grid.TableOptions.ListBoxSelectionMode to somthing other than None and setting grid.TableOptions.AllowSelection = GridSelectionFlags.None.

Ranjit
Replied On June 10, 2005 04:42 AM UTC

Thanks a ton!!! What I was tryin to achieve was allow the user to highlight rows in a group and sub group with different colors in GGC. The SelectedRecords did the trick. Regards, Ranjit

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.

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

;