Exemplo n.º 1
0
        void OnAutoGeneratingColumn(object sender, GridAutoGeneratingColumnEventArgs e)
        {
            string propertyName       = e.Property.Name;
            int    propertyNameLength = e.Property.Name.Length;

            string column = propertyName.Substring(5, propertyNameLength - 5);
            int    columnNumber;
            bool   successfullyParsed = Int32.TryParse(column, out columnNumber);

            if (successfullyParsed)
            {
                if (columnNumber > _report.Headers.Count)
                {
                    e.Cancel = true;
                }
                else
                {
                    string dataType = _report.Headers[columnNumber - 1].DataType;
                    Debug.WriteLine(dataType);
                    if (dataType == "decimal" || dataType == "int" || dataType == "money")
                    {
                        e.Column.HorizontalAlignment = LayoutAlignment.End;
                        e.Column.Format    = "N0";
                        e.Column.Aggregate = GridAggregate.Sum;
                    }
                }
            }
        }
Exemplo n.º 2
0
 private void OnAutoGeneratingColumn(object sender, GridAutoGeneratingColumnEventArgs e)
 {
     if (e.Property.Name == "FirstName" || e.Property.Name == "LastName")
     {
         e.Column.Width = GridLength.Star;
     }
 }
Exemplo n.º 3
0
        private void OnAutoGeneratingColumn(object sender, GridAutoGeneratingColumnEventArgs e)
        {
            var columns = new string[] { "FirstName", "LastName", "Country", "City" };

            if (!columns.Contains(e.Property.Name))
            {
                e.Cancel = true;
            }
            e.Column.Width    = new GridLength(1, GridUnitType.Star);
            e.Column.MinWidth = double.NaN;
        }
Exemplo n.º 4
0
 private void OnAutoGeneratingColumn(object sender, GridAutoGeneratingColumnEventArgs e)
 {
     if (e.Property.Name == "Country" || e.Property.Name == "Name" || e.Property.Name == "OrderAverage")
     {
         //Avoids generating these columns
         e.Cancel = true;
     }
     else if (e.Property.Name == "Id")
     {
         e.Column.IsReadOnly = true;
     }
     else if (e.Property.Name == "CountryId")
     {
         //Sets the DataMap to the country column so a picker is used to select the country.
         e.Column.Header = "Country";
         e.Column.HorizontalAlignment = LayoutAlignment.Start;
         e.Column.DataMap             = new GridDataMap()
         {
             ItemsSource = Customer.GetCountries(), DisplayMemberPath = "Value", SelectedValuePath = "Key"
         };
     }
     else if (e.Property.Name == "OrderTotal" || e.Property.Name == "OrderAverage")
     {
         //Sets currency format the these columns
         e.Column.Format = "C";
     }
     else if (e.Property.Name == "LastOrderDate")
     {
         //Replaces the column so that the editor is a date-picker instead of an entry.
         e.Column = new GridDateTimeColumn(e.Property);
     }
     else if (e.Property.Name == "Address")
     {
         e.Column.WordWrap = true;
     }
 }