Grouping of Cells or Merging of Cells in Datagrid

Sep 2 2009 1:34 AM

Hi,
Actualy i have made a control like Weekly Outlook , i have made somehow every aspect of this but the issue that i am facing is i have to make certain cells grouped or merged , i have control this in a DATAGRID control , made runtime datagrid and give column a binding with my DATABASE , i successfully did that ,i want to mentioned my whole XAML.cs code ,please see the below code
 
private void BuildDataGrid()
{
// Create a new instance of the DataGrid class

// Configure some properties and data source
gdEmployees.AutoGenerateColumns =
false;
gdEmployees.CanUserSortColumns =
false;
//gdEmployees.ItemsSource = EmployeeManager.GetEmployeeList();
gdEmployees.IsReadOnly =
false;
gdEmployees.VerticalScrollBarVisibility =
ScrollBarVisibility.Auto;
gdEmployees.SetValue(
Grid.RowProperty, 2);
// Add the Grid to the Page
this.LayoutRoot.Children.Add(gdEmployees);
// Add the Time custom column
DataGridTextColumn Time = new DataGridTextColumn();
Time.Header = System.
DateTime.Now; //"Full Name";
Time.Binding =
new Binding("Time");
Time.IsReadOnly =
true;
gdEmployees.Columns.Add(Time);
 
 
// Add the Sunday column
DataGridTextColumn Sunday = new DataGridTextColumn();
Sunday.Header = System.
DateTime.Now.AddDays(-2).ToString();
Sunday.Binding =
new Binding("Sunday");
Sunday.IsReadOnly =
true;
gdEmployees.Columns.Add(Sunday);
// Add the Monday column
DataGridTextColumn Monday = new DataGridTextColumn();
Monday.Header = System.
DateTime.Now.AddDays(-1).ToString();
Monday.Binding =
new Binding("Monday");
Monday.IsReadOnly =
true;
gdEmployees.Columns.Add(Monday);
 
// Add the Tuesday column
DataGridTextColumn Tuesday = new DataGridTextColumn();
Tuesday.Header = System.
DateTime.Now;
Tuesday.Binding =
new Binding("Tuesday");
Tuesday.IsReadOnly =
true;
gdEmployees.Columns.Add(Tuesday);
 
// Add the Wednesday column
DataGridTextColumn Wednesday = new DataGridTextColumn();
Wednesday.Header = System.
DateTime.Now.AddDays(1).ToString();
Wednesday.Binding =
new Binding("Wednesday");
Wednesday.IsReadOnly =
true;
gdEmployees.Columns.Add(Wednesday);
// Add the Thursday column
DataGridTextColumn Thursday = new DataGridTextColumn();
Thursday.Header = System.
DateTime.Now.AddDays(2).ToString();
Thursday.Binding =
new Binding("Thursday");
Thursday.IsReadOnly =
true;
gdEmployees.Columns.Add(Thursday);
// Add the Friday column
DataGridTextColumn Friday = new DataGridTextColumn();
Friday.Header = System.
DateTime.Now.AddDays(3).ToString();
Friday.Binding =
new Binding("Friday");
Friday.IsReadOnly =
true;
gdEmployees.Columns.Add(Friday);
// Add the Saturday column
DataGridTextColumn Saturday = new DataGridTextColumn();
Saturday.Header = System.
DateTime.Now.AddDays(4).ToString();
Saturday.Binding =
new Binding("Saturday");
Saturday.IsReadOnly =
true;
gdEmployees.Columns.Add(Saturday);
 

}
 
The binding for the column entries handled in another function ,in which i have looped through my all DB rows using Foreach loop , and add that row by row in a LIST (generic type) and give that LIST to source to DATAGRID , i have made 15 minute distribution with the Weekly representation ,if a person have appointement of 45 mins then it give a view like it distributed into 3 cells separatly,i want to make these 3 cells merge together,i think you understand my point of view,please help me out to resolve this issue

Answers (2)