using System;
using System.Collections.Generic;
using System.Collections;
using System.Text;
using FastReport.Utils;
namespace FastReport.Dialog
{
///
/// Represents the collection of GridControl columns.
///
public class GridControlColumnCollection : FRCollectionBase, IFRSerializable
{
///
/// Gets or sets a column.
///
/// The index of a column in this collection.
/// The column with specified index.
public GridControlColumn this[int index]
{
get { return List[index] as GridControlColumn; }
set { List[index] = value; }
}
///
protected override void OnInsert(int index, Object value)
{
base.OnInsert(index, value);
if (Owner != null)
{
GridControlColumn column = value as GridControlColumn;
(Owner as GridControl).DataGridView.Columns.Insert(index, column.Column);
}
}
///
protected override void OnRemove(int index, object value)
{
base.OnRemove(index, value);
if (Owner != null)
{
GridControlColumn column = value as GridControlColumn;
(Owner as GridControl).DataGridView.Columns.Remove(column.Column);
}
}
///
/// Serializes the collection.
///
/// Writer object.
///
/// This method is for internal use only.
///
public void Serialize(FRWriter writer)
{
writer.ItemName = "Columns";
foreach (GridControlColumn c in this)
{
writer.Write(c);
}
}
///
/// Deserializes the collection.
///
/// Reader object.
///
/// This method is for internal use only.
///
public void Deserialize(FRReader reader)
{
Clear();
while (reader.NextItem())
{
GridControlColumn c = new GridControlColumn();
reader.Read(c);
Add(c);
}
}
///
/// Initializes a new instance of the class with default settings.
///
public GridControlColumnCollection() : this(null)
{
}
///
/// Initializes a new instance of the class with default settings.
///
/// The owner of this collection.
public GridControlColumnCollection(GridControl owner) : base(owner)
{
}
}
}