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 : Nov 16th 2018).
Unfortunately, activation email could not send to your email. Please try again.
Syncfusion Feedback

Various Issues

Thread ID:

Created:

Updated:

Platform:

Replies:

18636 Sep 5,2004 09:50 AM UTC Sep 10,2004 05:18 AM UTC WinForms 9
loading
Tags: Grouping
Steven Hawkes
Asked On September 5, 2004 09:50 AM UTC

Hi, Being new to Syncfuson I am finding things a bit heavy going and was wondering if you could recommend a good step by step tutorial on using these components, especially the grid and the grouping controls so I dont have to keep bothering this forum with basic issues. My current issues are as follows. I have a grouping grid with a single parent and one child. How do I : 1. Get a reference to an individual cell in the grid. 2. Change the background color of that cell at runtime. 3. Change the justification of a cell at runtime 4. Hide the cell showing the child ID as per the provided example. A more complex issue is I would like the window form to expand and collapse depending on if a child is open or closed (obviously within the limits of the screen). How best should one relate the number of viable rows to the size of a window form size? Thanks very much in advance for your help Regards Steve

Steven Hawkes
Replied On September 5, 2004 05:27 PM UTC

Point 3 should read 3. Changing the colour of a complete group row >Hi, > >Being new to Syncfuson I am finding things a bit heavy going and was wondering if you could recommend a good step by step tutorial on using these components, especially the grid and the grouping controls so I dont have to keep bothering this forum with basic issues. > >My current issues are as follows. I have a grouping grid with a single parent and one child. >How do I : > >1. Get a reference to an individual cell in the grid. >2. Change the background color of that cell at runtime. >3. Change the justification of a cell at runtime >4. Hide the cell showing the child ID as per the provided example. > >A more complex issue is I would like the window form to expand and collapse depending on if a child is open or closed (obviously within the limits of the screen). How best should one relate the number of viable rows to the size of a window form size? > >Thanks very much in advance for your help > >Regards > >Steve >

Administrator [Syncfusion]
Replied On September 7, 2004 12:31 PM UTC

Hi Steven, to change background color and justification of cells you would normally do this though column appearance, e.g. TableDescriptor.Columns["City"].Apperance.AnyRecordFieldCell.BackColor = Color.Blue; This will make the change appear for any cell of that column in the table. If you want to change the appear of specific cells (e.g. based on some dynamic criteria) you can handle the QueryCellStyleInfo event instead e.g. this.gridGroupingControl1.QueryCellStyleInfo += new Syncfusion.Windows.Forms.Grid.Grouping.GridTableCellStyleInfoEventHandler(gridGroupingControl1_QueryCellStyleInfo); private void gridGroupingControl1_QueryCellStyleInfo(object sender, Syncfusion.Windows.Forms.Grid.Grouping.GridTableCellStyleInfoEventArgs e) { // Record Record r = style.TableCellIdentity.DisplayElement.ParentRecord; // Column ColumnDescriptor column = style.TableCellIdentity.Column; // Get Field if (column != null && (e.TableCellIdentity.TableCellType == GridTableCellType.RecordFieldCell || e.TableCellIdentity.TableCellType == GridTableCellType.AlternateRecordFieldCell)) { object value = r.GetValue(column.FieldDescriptor); if (value is someCriteria) e.Style.BackColor = Color.Red; // BTW - If you need record index or unsorted record index int recordIndex = r.ParentTable.Records.IndexOf(r); int unsortedrecordIndex = r.ParentTable.UnsortedRecords.IndexOf(r); } } To hide a specific column, you can simple remove the column from the TableDescriptor.VisibleColumns collection. If you want to highlight records on criteria check out also ConditionalFormats. Stefan

Steven Hawkes
Replied On September 8, 2004 10:05 AM UTC

Hi, Thanks for the response. I tried the solution but it did not work. The problem is that the Record "r" is always undefined, any ideas why? The second issue is that I want to change the colour of a complete row and not a column. These rows are the rows with the + header information, parent rows. TIA

Administrator [Syncfusion]
Replied On September 8, 2004 11:01 AM UTC

Hi Steven, ParentRecord will only return a record if the queried element is a RecordRow. You can check the tableCellIdentity.DisplayElement to find out what element is queried for. What you probably are interested in is CaptionRows. These are the rows for the group (and they won''t have a parent record). The possible TableCellType(s) for a Caption Rows are /// /// PlusMinus cell in group caption /// GroupCaptionPlusMinusCell, /// /// Group caption cell /// GroupCaptionCell, /// /// Any cell in group header section. /// The QueryCellStyleInfo will be called for each column in that row, so you can format the whole row. But since you mentioned you are only interested in Group captions and not individual records ... Another option you have is to get the group directly and then set its group.Appearance.GroupCaptionCell.BackColor or group.Appearance.AnyCaptionCell.BackColor The GroupCustomer sample shows how to get a reference to a specific group: int index = this.groupingGrid1.Table.TopLevelGroup.Groups.FindGroup("Germany"); if (index != -1) { Group germanyGroup2 = this.groupingGrid1.Table.TopLevelGroup.Groups[index]; Trace.WriteLine(germanyGroup2); } // Now you can set appearance here. Stefan

Steven Hawkes
Replied On September 8, 2004 04:15 PM UTC

This looks like what I want but the example that I was posted from this forum does not specify group names. Is there a way to get the names of the groups held within a grouping grid. Then I should have everything. Thanks >Hi Steven, > >ParentRecord will only return a record if the queried element is a RecordRow. You can check the tableCellIdentity.DisplayElement to find out what element is queried for. > >What you probably are interested in is CaptionRows. These are the rows for the group (and they won''t have a parent record). > >The possible TableCellType(s) for a Caption Rows are > > > /// > /// PlusMinus cell in group caption > /// > GroupCaptionPlusMinusCell, > /// > /// Group caption cell > /// > GroupCaptionCell, > /// > /// Any cell in group header section. > /// > > >The QueryCellStyleInfo will be called for each column in that row, so you can format the whole row. > >But since you mentioned you are only interested in Group captions and not individual records ... > >Another option you have is to get the group directly and then set its group.Appearance.GroupCaptionCell.BackColor or >group.Appearance.AnyCaptionCell.BackColor > >The GroupCustomer sample shows how to get a reference to a specific group: > > > int index = this.groupingGrid1.Table.TopLevelGroup.Groups.FindGroup("Germany"); > if (index != -1) > { > Group germanyGroup2 = this.groupingGrid1.Table.TopLevelGroup.Groups[index]; > Trace.WriteLine(germanyGroup2); > } > >// Now you can set appearance here. > > >Stefan > > >

Administrator [Syncfusion]
Replied On September 8, 2004 06:00 PM UTC

Steven, when you call FindGroup("Germany") in the example, "Germany" is not the name of the group. Instead it is the CategoryValue of the group. If you do have groups, then they must be categorized and you can use their categorie values for lookup. Try enumerating though TopLevelGroup.Groups and check group.CategoryKey for each group. Then you''ll get the Categories in your table. Stefan

Steven Hawkes
Replied On September 9, 2004 03:27 AM UTC

Hi, Thanks for the response. I did what you suggested and received the group but where is the Appearance property, I can not see it? In addition, I want to Form to increase / decrease in size to always show all entries in the grouping grid without the need to use scroll bars. My initial thoughts were to perform a calculation based on the number of visual rows and to set the "clientsize" accordingly, thinking there must be a way to determine the number fo visable rows including Caption Rows. Can you suggest a better alternative? Sorry for the somwhat simple questions but I am a total beginner to this library. Thank you for your patience.

Administrator [Syncfusion]
Replied On September 9, 2004 11:24 AM UTC

Hi Steven, don''t worry about asking questions. It''s good for us developers to get a feel what people try to do and will also help us with improving documentation. The Group object needs to be casted to GridGroup. Then you''ll get access to the appearance property. Regarding the sizing of the grid. You can use the Table.GetYAmountCount() method. That will return you the total size of the grid in pixels. You can then listen to group/record expanding events and resize the control. Example: // In your Forms ctor after calling InitializeComponent: AutoSizeHeightOfGrid(); this.gridGroupingControl1.RecordExpanded += new RecordEventHandler(gridGroupingControl1_RecordExpanded); this.gridGroupingControl1.RecordCollapsed += new RecordEventHandler(gridGroupingControl1_RecordCollapsed); this.gridGroupingControl1.GroupExpanded += new GroupEventHandler(gridGroupingControl1_GroupExpanded); this.gridGroupingControl1.GroupCollapsed += new GroupEventHandler(gridGroupingControl1_GroupCollapsed); // Add these methods to form private void gridGroupingControl1_RecordExpanded(object sender, RecordEventArgs e) { AutoSizeHeightOfGrid(); } private void gridGroupingControl1_RecordCollapsed(object sender, RecordEventArgs e) { AutoSizeHeightOfGrid(); } private void gridGroupingControl1_GroupExpanded(object sender, GroupEventArgs e) { AutoSizeHeightOfGrid(); } private void gridGroupingControl1_GroupCollapsed(object sender, GroupEventArgs e) { AutoSizeHeightOfGrid(); } void AutoSizeHeightOfGrid() { int height = (int) this.gridGroupingControl1.Table.GetYAmountCount(); height += SystemInformation.HorizontalScrollBarHeight; height += 2; // Borders this.gridGroupingControl1.Bounds = new Rectangle(10, 10, ClientSize.Width-20, height); } Stefan

Steven Hawkes
Replied On September 10, 2004 05:18 AM UTC

Great, this all seems to work. Thanks for your help I have another question but this should be a new thread I think Cheers

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

;