Your Privacy Matters: We use our own and third-party cookies to improve your experience on our website. By continuing to use the website we understand that you accept their use. Cookie Policy
315
Vertical align column values
posted

Is there an easy way to make column cell values be vertically aligned to the top?  Basically, I have one column where the values wrap, so a row could end up being very tall...off the screen tall.  That means the other values on that row would be in the middle vertically, so the user has to scroll way down to see them.  I would like to set all my columns to vertically align values to the top, but don't see that on IGGridViewColumnDefinition, just "textAlignment", which is horizontal alignment.  Thanks!

Parents
  • 40030
    Offline posted

    Hi Michael, 

    In iOS a UILabel doesn't have a vertical textAlignment property. It always align text in the middle of the UILabel. The way you control positioning on the vertical axis, is by positioning the label and having it fit to the container. 

    You should be able to do this still with minimal code changes though. You would basically just create a custom cell:

    public partial class CustomCell : IGGridViewCell
    {
        public override void SetupSize (SizeF size)
        {
            base.SetupSize (size);

            this.TextLabel.SizeToFit ();
        }

    }

    Then all you need to do is tell the grid to use your cell by default: 

    grid.RegisterClassForCellReuse (new MonoTouch.ObjCRuntime.Class ("CustomCell"), "Cell");

    Hope this helps,

    -SteveZ

Reply Children