Exemplo n.º 1
0
    public void AddStateAttributes()
    {
        GridFieldLayout.Fields.BeginUpdate();
        // Remove the current columns (except for StateName)
        var removableFields = GridFieldLayout.Fields.Where(f => f.Name != "StateName");

        removableFields.ToList().ForEach(field => GridFieldLayout.Fields.Remove(field));

        // Figure out what state attributes to add
        var random    = new Random(DateTime.Now.Millisecond);
        var numCols   = random.Next(1, 6);
        var colsToAdd = GetStateAttributes(numCols, random);

        // Finally add the new ones'
        foreach (var col in colsToAdd)
        {
            var field = new UnboundField();
            field.Name    = col;
            field.Binding = new Binding()
            {
                Mode = BindingMode.TwoWay,
                Path = new PropertyPath(string.Format("[{0}]", col)),
                UpdateSourceTrigger = UpdateSourceTrigger.PropertyChanged
            };
            GridFieldLayout.Fields.Add(field);
        }
        GridFieldLayout.Fields.EndUpdate();
    }
Exemplo n.º 2
0
 public void GenerateGridFields(List <DateTime> timeStamps)
 {
     foreach (DateTime dt in timeStamps)
     {
         UnboundField field = new UnboundField();
         field.Name  = dt.ToString();
         field.Label = string.Format("{0}/{1}-{2}", dt.Month.ToString(), dt.Day.ToString(), dt.ToShortTimeString());
         this.xdgTests.FieldLayouts[0].Fields.Add(field);
     }
 }