예제 #1
0
        ///  <summary>
        ///  Regular columns but with an image.
        ///  </summary>
        public OLVColumn CreateImageColumn <TImageKey>(
            string headerText,
            Func <TRow, IComparable> getSortValue,
            Func <TRow, TImageKey> funcThatRetunsImageListKeyString,
            Func <TImageKey, Image> getImage,
            bool cacheImagesInImageList,
            ColumnRenderType columnType = ColumnRenderType.Default)
        {
            var col = CreateColumn(headerText, getSortValue, null, columnType);

            col.ImageGetter = x =>
            {
                try
                {
                    TImageKey imageKey = funcThatRetunsImageListKeyString((TRow)x);

                    if (cacheImagesInImageList)
                    {
                        return(GetImageName(imageKey, () => getImage(imageKey)));
                    }

                    return(getImage(imageKey));
                }
                catch
                {
                    return(null);
                }
            };

            col.AspectToStringConverter = x => string.Empty; // do not show string
            return(col);
        }
예제 #2
0
        /// <summary>
        /// Create a standard column.
        /// </summary>
        public OLVColumn CreateColumn <TColumn>(
            string headerText,
            Func <TRow, TColumn> getValue,
            Func <TColumn, string> valueToString,
            ColumnRenderType columnType = ColumnRenderType.Default)
        {
            OLVColumn column = new OLVColumn
            {
                AspectGetter = rowObject =>
                {
                    try
                    {
                        return(getValue((TRow)rowObject));
                    }
                    catch
                    {
                        return(null);
                    }
                },
                Text = headerText,
                Tag  = _gridHelper
            };

            if (valueToString != null)
            {
                column.AspectToStringConverter = rowObject => rowObject == null ? "(NULL)" : valueToString((TColumn)rowObject);
            }

            _columns.Add(new ObjColumn(columnType));
            _grid.AllColumns.Add(column);
            return(column);
        }
예제 #3
0
 /// <summary>
 /// Create a standard column.
 /// </summary>
 public OLVColumn CreateColumn(
     string headerText,
     Func <TRow, string> getValue,
     ColumnRenderType columnType = ColumnRenderType.Default)
 {
     return(CreateColumn(headerText, getValue, null, columnType));
 }
예제 #4
0
        /*
         * how to use!
         *   private GridImageKind EnabledImageGetter(object rowObject)
         *  {
         *      return ((Analyzer)rowObject).Enabled ? GridImageKind.check : GridImageKind.cross;
         *  }
         *   var EnabledImages = new List<GridImageKind>() {GridImageKind.check,GridImageKind.cross};
         *  _gridHelper.CreateImageColumn(x => x.Enabled, EnabledImageGetter, EnabledImages, "Enabled");
         */

        ///  <summary>
        ///  Regular columns but with an image.
        ///
        ///  </summary>
        /// <param name="getSortValue"></param>
        /// <param name="headerText"></param>
        /// <param name="columnType"></param>
        /// <param name="getRowImage">a function that returns a key as string in your image list but as object</param>
        public OLVColumn CreateImageColumn(
            string headerText,
            Func <TRow, IComparable> getSortValue,
            Func <TRow, GridImageKind> getRowImage,
            ColumnRenderType columnType = ColumnRenderType.Default)
        {
            return(CreateImageColumn(
                       headerText,
                       getSortValue,
                       getRowImage,
                       GridImageHelper.GetImage,
                       true,
                       columnType));
        }
예제 #5
0
        /// <summary>
        /// Basic column but with something that looks like a hyperlink.
        /// <para>you decide what you want to happen.</para>
        /// </summary>
        public OLVColumn CreateHyperlinkColumn(
            string headerText,
            Func <TRow, string> getValue,
            Action <TRow> onClicked,
            ColumnRenderType columnType = ColumnRenderType.Default)
        {
            var column = CreateColumn(headerText, getValue, null, columnType);

            _grid.UseHyperlinks = true;
            column.Hyperlink    = true;
            EventHandler <HyperlinkClickedEventArgs> gridOnHyperlinkClicked = (sender, args) =>
            {
                if (args.Column.Text.Equals(column.Text))
                {
                    onClicked((TRow)args.Model);
                }
                args.Handled = true;    //disables the process start default process
            };

            _grid.HyperlinkClicked += gridOnHyperlinkClicked;
            _gridHelper.AddDisposedAction(() => _grid.HyperlinkClicked -= gridOnHyperlinkClicked);
            return(column);
        }
예제 #6
0
        /// <summary>
        /// Regular columns but with a checkbox.
        /// </summary>
        public OLVColumn CreateCheckboxColumn(string headerText, Func <TRow, string> getValue, ColumnRenderType columnType = ColumnRenderType.Default)
        {
            var col = CreateColumn(headerText, getValue, null, columnType);

            col.CheckBoxes         = true;
            col.TriStateCheckBoxes = true;
            col.FillsFreeSpace     = false;
            var size = _grid.Font.GetTextSize(headerText);

            col.Width = (int)size.Width + _grid.Margin.Left + _grid.Margin.Right;
            return(col);
        }
예제 #7
0
 public ObjColumn(ColumnRenderType columnRenderType)
 {
     ColumnRenderType = columnRenderType;
 }