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

Populate a GridGroupingControl from text values

Thread ID:





11454 Mar 5,2004 07:53 PM UTC Mar 8,2004 08:50 AM UTC WinForms 3
Tags: Grouping
Asked On March 5, 2004 07:53 PM UTC

Hi. I have a GridGroupingControl which I would like to populate. I am receiving log messages via .NET remoting and have the values in string format. What is the simplest way that I can take these log messages and display them in a GridGroupingControl? I have the fields: ID, Message, Service, Date, Level. I receive a new log object with these values every few seconds. Thanks, David

Administrator [Syncfusion]
Replied On March 5, 2004 10:42 PM UTC

You should create a DataTable object and set it as datasource for the control. When you add new records to the table the new rows will automatically show up in the grid. Here is some code that shows how to create and add a records to a DataTable. private void InitializeDataTable() { int recordCount = 100; Random random = new Random(DateTime.Now.Millisecond); string[] states = new string[]{"North Carolina", "South Carolina", "Washington", "Nevada", "Ohio"}; int numStates = states.GetLength(0); string nameFormat = "Name{0}"; this.table = new DataTable("Test"); DataColumn col = table.Columns.Add(); col.DataType = typeof(string); col.ColumnName = "Name"; col = table.Columns.Add(); col.DataType = typeof(string); col.ColumnName = "State"; col = table.Columns.Add(); col.DataType = typeof(int); col.ColumnName = "Zip"; for(int i = 0; i < recordCount; i++) { DataRow row = this.table.NewRow(); row["Name"] = string.Format(nameFormat, i); row["State"] = states[random.Next(numStates-1)]; row["Zip"] = random.Next(9999); this.table.Rows.Add(row); } } Stefan Hoenig

Replied On March 7, 2004 05:39 PM UTC

This is perfect! Thanks. One more quick question though. Using the DataTable as you''ve described, how do I tell the GridGroupingControl to stretch the grid to fill the entire width of the control? I''ve docked it as "Fill" and it''s anchored to the upper left. Is there a property I should set that does automatic stretching and column resizing? Thanks!

Administrator [Syncfusion]
Replied On March 8, 2004 08:50 AM UTC

Currently, there is no property to handle this. But you can catch an event and do the sizing tere to fill up the client area. Here are some snippets that make the right-most column fill the client area. //in formload this.gridGroupingControl1.TableControl.Model.QueryColWidth += new GridRowColSizeEventHandler(grid_QueryColWidth); this.SCROLLBARWIDTH = SystemInformation.VerticalScrollBarWidth; this.lastCol = myDataTable.Columns.Count + 1;
//the handler
private void grid_QueryColWidth(object sender, GridRowColSizeEventArgs e)
	if(e.Index == this.lastCol)
		int vscrollwidth = ((this.gridGroupingControl1.TableControl.Model.RowHeights.GetTotal(0, this.gridGroupingControl1.TableControl.Model.RowCount)  
					+  this.gridGroupingControl1.TableOptions.CaptionRowHeight)
					> this.gridGroupingControl1.ClientSize.Height) 
		e.Size = this.gridGroupingControl1.ClientSize.Width - 
				this.gridGroupingControl1.TableControl.Model.ColWidths.GetTotal(0, e.Index - 1)
				- vscrollwidth;
		e.Handled = true;


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