private string SerializeColumns()
    {
        StringBuilder sb = new StringBuilder();

        using (XmlWriter xw = XmlWriter.Create(sb)) {
            xw.WriteStartDocument();

            GridViewInfo g = new GridViewInfo(grid);
            foreach (GridViewColumn column in grid.Columns)
            {
                if (column is GridViewDataColumn)
                {
                    g.Columns.Add(new DataColumnInfo(column as GridViewDataColumn));
                }
                else if (column is GridViewCommandColumn)
                {
                    g.Columns.Add(new CommandColumnInfo(column as GridViewCommandColumn));
                }
                else if (column is GridViewBandColumn)
                {
                    g.Columns.Add(new BandColumnInfo(column as GridViewBandColumn));
                }
            }
            XmlSerializer xmlSerializer = new XmlSerializer(g.GetType());
            xmlSerializer.Serialize(xw, g);
        }
        return(sb.ToString());
    }
        private GridCellInfo GetGridCellInfo(GridViewInfo viewInfo, GridCell cell)
        {
            GridCellInfo gridCellInfo = viewInfo.GetGridCellInfo(cell.RowHandle, cell.Column);

            gridCellInfo.State &= ~(GridRowCellState.Focused | GridRowCellState.FocusedCell | GridRowCellState.Selected);
            System.Reflection.MethodInfo method = viewInfo.GetType().GetMethod("UpdateCellAppearanceCore", System.Reflection.BindingFlags.Instance | System.Reflection.BindingFlags.NonPublic);
            method.Invoke(viewInfo, new object[] { gridCellInfo, true, true, null });
            return(gridCellInfo);
        }
Ejemplo n.º 3
0
        AppearanceObject GetCellAppearance(int gridRowHandle, GridColumn gridColumn)
        {
            GridViewInfo viewInfo = view.GetViewInfo() as GridViewInfo;
            GridCellInfo cellInfo = viewInfo.GetGridCellInfo(gridRowHandle, gridColumn);

            if (cellInfo == null)
            {
                cellInfo = new GridCellInfo(new GridColumnInfoArgs(gridColumn), new GridDataRowInfo(viewInfo, gridRowHandle, view.GetRowLevel(gridRowHandle)), Rectangle.Empty);
            }
            MethodInfo me = viewInfo.GetType().GetMethod("UpdateCellAppearance", BindingFlags.Instance | BindingFlags.NonPublic | BindingFlags.DeclaredOnly);

            if (me != null)
            {
                me.Invoke(viewInfo, new object[] { cellInfo, true });
            }
            viewInfo.UpdateCellAppearance(cellInfo);
            return(cellInfo.Appearance);
        }