当前位置: 首页>>代码示例>>C#>>正文


C# ListView.GetAspectValue方法代码示例

本文整理汇总了C#中ListView.GetAspectValue方法的典型用法代码示例。如果您正苦于以下问题:C# ListView.GetAspectValue方法的具体用法?C# ListView.GetAspectValue怎么用?C# ListView.GetAspectValue使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在ListView的用法示例。


在下文中一共展示了ListView.GetAspectValue方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: SampleDesktop


//.........这里部分代码省略.........

                TextBox txt = new TextBox();
                txt.Text = "lorem ipsum";
                txt.Size = new Squid.Point(222, 35);
                txt.Position = new Point(110, 10 + 45 * i);
                txt.Style = "textbox";
                txt.AllowDrop = true;
                txt.TabIndex = 1 + i;
                txt.DragDrop += txt_OnDragDrop;
                txt.GotFocus += txt_OnGotFocus;
                panel.Content.Controls.Add(txt);
            }

            #endregion

            #region sample window 6 - ListView

            SampleWindow window6 = new SampleWindow();
            window6.Size = new Point(440, 340);
            window6.Position = new Point(960, 400);
            window6.Resizable = true;
            window6.Titlebar.Text = "Misc";
            window6.Parent = this;

            Random rnd = new Random();
            List<MyData> models = new List<MyData>();
            for (int i = 0; i < 32; i++)
            {
                MyData data = new MyData();
                data.Name = rnd.Next().ToString();
                data.Date = DateTime.Now.AddMilliseconds(rnd.Next());
                data.Rating = rnd.Next();
                models.Add(data);
            }

            ListView olv = new ListView();
            olv.Dock = DockStyle.Fill;
            olv.Columns.Add(new ListView.Column { Text = "Name", Aspect = "Name", Width = 120 });
            olv.Columns.Add(new ListView.Column { Text = "Date", Aspect = "Date", Width = 120 });
            olv.Columns.Add(new ListView.Column { Text = "Rating", Aspect = "Rating", Width = 120 });
            olv.StretchLastColumn = false;
            olv.FullRowSelect = true;

            olv.CreateHeader = delegate(object sender, ListView.FormatHeaderEventArgs args)
            {
                Button header = new Button
                {
                    Dock = DockStyle.Fill,
                    Text = args.Column.Text,
                    AllowDrop = true
                };

                header.MouseClick += delegate(Control snd, MouseEventArgs e)
                {
                    if (args.Column.Aspect == "Name")
                        olv.Sort<MyData>((a, b) => a.Name.CompareTo(b.Name));
                    else if (args.Column.Aspect == "Date")
                        olv.Sort<MyData>((a, b) => a.Date.CompareTo(b.Date));
                    else if (args.Column.Aspect == "Rating")
                        olv.Sort<MyData>((a, b) => a.Rating.CompareTo(b.Rating));
                };

                header.MouseDrag += delegate(Control snd, MouseEventArgs e)
                {
                    Label drag = new Label();
                    drag.Size = snd.Size;
                    drag.Position = snd.Location;
                    drag.Style = snd.Style;
                    drag.Text = ((Button)snd).Text;

                    DoDragDrop(drag);
                };

                header.DragDrop += delegate(Control snd, DragDropEventArgs e)
                {

                };

                return header;
            };

            olv.CreateCell = delegate(object sender, ListView.FormatCellEventArgs args)
            {
                return new Button
                {
                    Size = new Point(28, 28),
                    Dock = DockStyle.Top,
                    Text = olv.GetAspectValue(args.Model, args.Column),
                    Tooltip = args.Column.Text
                };
            };

            olv.SetObjects(models);

            window6.Controls.Add(olv);

            #endregion

            #endregion
        }
开发者ID:ndssia,项目名称:Corsair3,代码行数:101,代码来源:SampleDesktop.cs


注:本文中的ListView.GetAspectValue方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。