Home - Forums-.NET - FlyGrid.Net (Windows Forms) - Image allignment

FlyGrid.Net (Windows Forms)

.NET Datagrid - Fast, highly customizable, industry standards .NET data grid control for WinForms

This forum related to following products: FlyGrid.Net

Image allignment
Link Posted: 15-Apr-2007 15:11
I've created a bunch of columns in my grid, specifying

icol.ImageAlign = ContentAlignment.MiddleCenter;

for each. Then I've added some rows with images using Node(object[]{..}), yet all images align to top-left corner.

Any suggestions would be welcomed.
Link Posted: 15-Apr-2007 17:35
Could you provide us with a sample to more precisely answer you question.
Please send your sample to , zip your file and change extension to the .zip.txt or .zap.
Link Posted: 16-Apr-2007 06:02
Here are code excerpts:

ACLColumn class:

    class ACLColumn : ImageColumn {
        public ACLColumn() : base() { this.ImageAlign = ContentAlignment.MiddleCenter; }
        public ACLColumn(string name) : base(name) {
        }
        public ACLColumn(string name, string fieldName) : base(name, fieldName) { }
//....
}


... creating the grid columns ...


//.....
        public void Initialize() {

            /*
             * Initialize security list
             * */

            this.lvSecurity.Columns.Options |= ColumnsOptions.FitToWidth;
            this.lvSecurity.BeginInit();
            this.lvSecurity.Columns.Items.Clear();

            this.lvSecurity.Rows.Items.Clear();
            this.lvSecurity.Style = GridStyle.OfficeXP;

            try {
                for (int i = 0; i < 9; i++) {
                    Column col = new Column();
                    ACLColumn icol = new ACLColumn();
                    bool bText = false;
                    switch (i) {
                        case 1:
                            col.Width = 200;
                            col.FitMode = ColumnFitMode.Spring;
                            col.Caption = \"Name\";
                            bText = true;
                            break;
                        case 2:
                            col.Width = 100;
                            col.FitMode = ColumnFitMode.Spring;
                            col.Caption = \"Type\";
                            bText = true;
                            break;
                        case 8:
                            col.Visible = false;
                            bText = true;
                            break;
                        default:
                            icol.Width = 20;
                            //icol.FitMode = ColumnFitMode.Exact;
                            icol.ScaleImage = false;
                            icol.AllowSizing = false;
                            icol.ImageAlign = ContentAlignment.MiddleRight;
                            icol.AllowMove = false;
                            icol.AllowSorting = false;
                            icol.TooltipText = \"\";
                            break;
                    }
                    if (bText) {
                        col.ReadOnly = true;
                        this.lvSecurity.Columns.Items.Add(col);
                    } else {
                        icol.ReadOnly = true;
                        icol.Tag = (i == 0) ? null : ((new string[] { \"read\", \"write\", \"execute\", \"setPolicy\", \"traverse\" })[i - 3]);
                        this.lvSecurity.Columns.Items.Add(icol);
                    }
                }

            } finally {
                this.lvSecurity.EndInit();
            }

            /*
             * Initialize reports list
             * */

//...


... populating columns with data and images ...

(in the next replly ...)
Link Posted: 16-Apr-2007 06:05
... populating columns with text and image


//...
        private void addSecurityRow(PortalTreeNode ptn, XmlNode objPermissions) {
            //Check if we have an object in yet
            int intIndex = securityObjectIndex(ptn.SearchPath);
            if (intIndex == -1) {
                object[] nRow;
                if (objPermissions == null) {
                    nRow = new object[] {
                    getSecurityObjectIcon(ptn.Type),
                    ptn.DefaultName,
                    ptn.Type.ToString(),
                    Helper.getPermissionIcon(null),
                    Helper.getPermissionIcon(null),
                    Helper.getPermissionIcon(null),
                    Helper.getPermissionIcon(null),
                    Helper.getPermissionIcon(null),
                    ptn.SearchPath };
                } else {
                    nRow = new object[] {
                    getSecurityObjectIcon(ptn.Type),
                    ptn.DefaultName,
                    ptn.Type.ToString(),
                    Helper.getPermissionIcon(objPermissions.SelectSingleNode(\"item[name='read']\")),
                    Helper.getPermissionIcon(objPermissions.SelectSingleNode(\"item[name='write']\")),
                    Helper.getPermissionIcon(objPermissions.SelectSingleNode(\"item[name='execute']\")),
                    Helper.getPermissionIcon(objPermissions.SelectSingleNode(\"item[name='setPolicy']\")),
                    Helper.getPermissionIcon(objPermissions.SelectSingleNode(\"item[name='traverse']\")),
                    ptn.SearchPath };
                }
                Node node = new Node(nRow);
                this.lvSecurity.Rows.Items.Add(node);
            } else {
            }
        }
//...


and the Helper class


//...
class Helper {
        public static Image getPermissionIcon(XmlNode objPermission) {
            //Assembly assem = GetType().Assembly;
            Image img;
            if (objPermission == null)
                //stream = assem.GetManifestResourceStream(\"Security.Resources.access_none.gif\");
                img = (Image)Security.Properties.Resources.ResourceManager.GetObject(\"access_none\");
            else
                //stream = assem.GetManifestResourceStream(
                img = (Image)Security.Properties.Resources.ResourceManager.GetObject(\"access_\"
                    + objPermission.SelectSingleNode(\"name\").InnerText.Replace(\"setPolicy\", \"set_policy\")
                    + \"_\"
                    + objPermission.SelectSingleNode(\"access\").InnerText
                    + \"\");
            //Image img = Image.FromStream(stream);
            img.Tag = objPermission;
            return img;
        }

    }
//...
Link Posted: 18-Apr-2007 05:06
Any suggestions?