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


C# ListView.Focus方法代码示例

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


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

示例1: Show

    public static string Show()
    {
        //define the image list to contain all the file type icons
        ImageList imageList = new ImageList {
            ColorDepth = ColorDepth.Depth32Bit,
            ImageSize = new Size(32, 32)
        };
        imageList.Images.Add("asm", Icons.GetBitmap("filetype.asm", 32));
        imageList.Images.Add("c", Icons.GetBitmap("filetype.c", 32));
        imageList.Images.Add("cpp", Icons.GetBitmap("filetype.cpp", 32));
        imageList.Images.Add("h", Icons.GetBitmap("filetype.h", 32));
        imageList.Images.Add("cs", Icons.GetBitmap("filetype.cs", 32));
        imageList.Images.Add("vb", Icons.GetBitmap("filetype.vb", 32));
        imageList.Images.Add("unknown", Icons.GetBitmap("filetype.unknown", 32));

        //get the screen size so we can set the form
        //to fill 75% of the screen.
        Size screenSize = Screen.FromPoint(Cursor.Position).WorkingArea.Size;

        //create the form instance
        Form form = new Form() {
            Text = "Add solution item",
            ShowIcon = false,
            ShowInTaskbar = false,
            StartPosition = FormStartPosition.CenterScreen,
            FormBorderStyle = FormBorderStyle.FixedSingle,
            MaximizeBox = false,
            MinimizeBox = false,
            Size = new Size(600, 400)
                    //(int)(screenSize.Width * 0.75),
                    //(int)(screenSize.Height * 0.75)),
        };

        //create a panel that would contain everything so
        //we can easily get the actual working size we have
        //for the window
        Panel workingArea = new Panel() { Dock = DockStyle.Fill };
        form.Controls.Add(workingArea);

        //define the "add"/"cancel" buttons first so we can deturmine how
        //big everything would be to match it
        Button addButton = new Button() { Text = "Add" };
        Button cancelButton = new Button() { Text = "Cancel" };

        //deturmine the height of the input region
        int padding = 5;
        int inputRegionHeight = addButton.Height + (padding * 2);

        #region create the the list
        ListView list = new ListView() {
            Location = Point.Empty,
            Size = new Size(workingArea.Width, workingArea.Height - inputRegionHeight),
            LargeImageList = imageList,
            SmallImageList = imageList,
            View = View.LargeIcon,
        };
        workingArea.Controls.Add(list);
        addType(list, "asm", "c", "cpp", "h", "cs", "vb", "unknown");
        list.Focus();
        #endregion

        #region add the buttons
        Button[] buttons = { addButton, cancelButton };

        //add the buttons and calculate there position to be
        //displayed on the right side
        int currentButtonX = 0;
        for (int c = 0; c < buttons.Length; c++) {
            currentButtonX += buttons[c].Width + padding;

            int x = workingArea.Width - currentButtonX;
            int y =
                    (workingArea.Height - inputRegionHeight) +
                    (inputRegionHeight / 2) - (buttons[c].Height / 2);

            buttons[c].Location = new Point(x, y);
            workingArea.Controls.Add(buttons[c]);
        }

        #endregion

        #region Filename label
        //define the label
        Font filenameFont = new Font("Arial", 10, FontStyle.Bold);
        Label filenameLabel = new Label() {
            Text = "Filename:",
            Font = filenameFont
        };

        //define the location of the label to be at the beginning and centered
        //vertically.
        int filenameX = padding;
        int filenameY = (workingArea.Height - inputRegionHeight) +
                        (inputRegionHeight / 2) - (((int)filenameFont.GetHeight() + 1) / 2);
        filenameLabel.Location = new Point(filenameX, filenameY);
        workingArea.Controls.Add(filenameLabel);

        //calculate the end position x position of the label
        //so we know were to position the text box
        int filenameEndX = 75;//filenameLabel.Width + (padding * 2);
//.........这里部分代码省略.........
开发者ID:TomWilsonCoder,项目名称:oside,代码行数:101,代码来源:AddProjectItem.cs


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