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


C# ListView.AutoResizeColumn方法代码示例

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


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

示例1: MapLoad

    private async void MapLoad(object sender, EventArgs e)
    {
      var shapelayerText = FileLoader.LoadTextFile("config/shapelayers.json");
      var shapelayers = JsonConvert.DeserializeObject<List<Shapelayer>>(shapelayerText);
      var stationText = FileLoader.LoadTextFile("config/stations.json");
      var stations = JsonConvert.DeserializeObject<NexradStationFile>(stationText);

      var us_stations = stations.stationtable.station.Where(x => x.co == "US");
      var states = us_stations.GroupBy(x => x.st).OrderBy(x => x.Key);
      var list = new ListView();
      list.Columns.Add(new ColumnHeader() { Width = list.Width - 10 });
      list.HeaderStyle = ColumnHeaderStyle.None; 
      list.Alignment = ListViewAlignment.Left;
      list.AutoArrange = false;
      list.CheckBoxes = true;
      list.Margin = new Padding(30);
      list.Height = 500;
      list.Width = 250;
      list.ShowGroups = true;
      list.View = View.Details;
   
      foreach (var shapelayer in shapelayers)
      {
        if (list.Groups[shapelayer.category] == null)
        {
          list.Groups.Add(shapelayer.category, shapelayer.category);
        }
        var cur_renderable = new ShapeData(shapelayer.file, shapelayer.r, shapelayer.g, shapelayer.b, shapelayer.category, shapelayer.description);
        all_renderables.Add(cur_renderable);
        var item = list.Items.Add(shapelayer.description);
        item.Group = list.Groups[shapelayer.category];
        item.Checked = shapelayer.enabled;
        if (item.Checked)
        {
          load_renderables.Add(cur_renderable);
        }
      }

      for (int i = 0; i < states.Count(); i++)
      {
        var grp = list.Groups.Add(states.ElementAt(i).Key, states.ElementAt(i).Key);   
      }
      foreach(var station in us_stations){
        var cur_renderable = new RadarScan("K" + station.id, station.st);
        all_renderables.Add(cur_renderable);
        var item = list.Items.Add("K" + station.id + " " + station.name);
        item.Group = list.Groups[station.st];
        item.Checked = station.enabled;
        if (item.Checked)
        {
          load_renderables.Add(cur_renderable);
        }
      }

      list.AutoResizeColumn(0, ColumnHeaderAutoResizeStyle.ColumnContent);
      panel1.Controls.Add(list);
      list.ItemChecked += list_ItemChecked;


      loadThread = new Thread(new ThreadStart(loaderThreadFunc));
      loadThread.Start();
      loadThread2 = new Thread(new ThreadStart(loaderThreadFunc));
      loadThread2.Start();
      loadThread3 = new Thread(new ThreadStart(loaderThreadFunc));
      loadThread3.Start();

      overlayControl.OpenGLDraw += overlayControl_Draw;
      overlayControl.Resized += overlayControl_Resized;

      var gl = overlayControl.OpenGL;
      gl.Enable(OpenGL.GL_BLEND);
      gl.BlendFunc(BlendingSourceFactor.SourceAlpha, BlendingDestinationFactor.OneMinusSourceAlpha);
      var vertexShaderSource = FileLoader.LoadTextFile("Shader.vert");
      var fragmentShaderSource = FileLoader.LoadTextFile("Shader.frag");
      shaderProgram = new ShaderProgram();
      shaderProgram.Create(gl, vertexShaderSource, fragmentShaderSource, null);
      shaderProgram.BindAttributeLocation(gl, 0, "in_Position");
      shaderProgram.BindAttributeLocation(gl, 1, "in_Color");
      shaderProgram.AssertValid(gl);

      overlayControl_Resized(null, null);

      overlayControl.Click += overlayControl_Click;
      overlayControl.MouseMove += OnMouseMove;
      overlayControl.MouseDown += OnMouseDown;
      overlayControl.MouseUp += OnMouseUp;
      overlayControl.MouseWheel += overlayControl_MouseWheel;
    }
开发者ID:karlbloedorn,项目名称:InfoMap,代码行数:88,代码来源:Map.cs

示例2: ListViewResizeColumnInvoke

 private void ListViewResizeColumnInvoke(ListView listView, int column)
 {
     var totalColumnWidth = 0;
     var calculateColumnWidth = 0;
     for (int i = 0; i < listView.Columns.Count; i++)
     {
         if (column == 99)
         {
             if (i < listView.Columns.Count - 1)
             {
                 listView.AutoResizeColumn(i, ColumnHeaderAutoResizeStyle.ColumnContent);
             }
         }
         else
         {
             if (column != i)
             {
                 listView.AutoResizeColumn(i, ColumnHeaderAutoResizeStyle.ColumnContent);
                 totalColumnWidth += listView.Columns[i].Width;
             }
         }
     }
     #region FullFill
     if (column == 99)
     {
         listView.Columns[listView.Columns.Count - 1].Width = -2;
     }
     else
     {
         calculateColumnWidth = listView.Width - totalColumnWidth - (listView.Width / 10);//ลบด้วย 10% ของความกว้างทั้งหมดอีกรอบกันเลย
         listView.Columns[column].Width = calculateColumnWidth;
         listView.Columns[listView.Columns.Count - 1].Width = -2;
     }
     #endregion
 }
开发者ID:oofdui,项目名称:ContactCheckup-MassConvert,代码行数:35,代码来源:MapPayor.cs

示例3: ShowDataTableInListView

        /// <summary>
        /// Отобразить содержание DataTable в ListView элементе
        /// </summary>
        /// <param name="lv">ListView в котором отображаются данные</param>
        /// <param name="dt">DataTable из которого брать данные</param>
        private void ShowDataTableInListView(ListView lv, DataTable dt)
        {
            if(lv == null ||  dt == null) { throw new ArgumentNullException(); }
            if (lv.Columns.Count != dt.Columns.Count) { throw new ApplicationException("Не совпадает колчество столбоцов в ListView и DataTable"); }

            //Заполнение ListView элемента

            if (lv.Items.Count != 0) { lv.Items.Clear(); }
            lv.Tag = dt;                                        //сохраняем ссылку на отображаемую таблицу

            ListViewItem lvi;
            for (int i = 0; i < dt.Rows.Count; i++)
            {
                lvi = new ListViewItem();
                lvi.Text = dt.Rows[i]["id"].ToString();         //Столбец ИД(id)
                for (int j = 1; j < dt.Columns.Count; j++)
                {
                    //lvi.SubItems.Add(dt.Rows[i][j].ToString());
                    lvi.SubItems.Add(this.GetColumnText(dt.Rows[i], j));
                }
                lvi.Tag = dt.Rows[i];                           //сохраняем ссылку на отоброжаемую строку
                lv.Items.Add(lvi);
            }

            //Установка ширины столбцов(по заголовку)

            for (int i = 0; i < lv.Columns.Count; i++)
            {
                ColumnHeaderAutoResizeStyle style = (lv.Items.Count != 0) ? ColumnHeaderAutoResizeStyle.ColumnContent : ColumnHeaderAutoResizeStyle.HeaderSize;
                lv.AutoResizeColumn(i, ColumnHeaderAutoResizeStyle.HeaderSize);
            }
        }
开发者ID:Dr1N,项目名称:CinemaTickets,代码行数:37,代码来源:frmAdmin.cs

示例4: btnShowMakerCode_Click

        private void btnShowMakerCode_Click(object sender, EventArgs e)
        {
            System.Xml.Linq.XElement xml = Tools.Helper.GetTranslation("EditRomInfo");

            Form ven = new Form();
            ven.AutoScroll = true;
            ven.BackColor = SystemColors.GradientInactiveCaption;
            ven.FormBorderStyle = System.Windows.Forms.FormBorderStyle.FixedSingle;
            ven.ShowIcon = false;
            ven.ShowInTaskbar = false;
            ven.MaximizeBox = false;
            ven.MinimizeBox = false;
            ven.Size = new System.Drawing.Size(300, 700);

            ListView list = new ListView();
            list.Dock = DockStyle.Fill;
            list.View = View.Details;
            ColumnHeader columnCode = new ColumnHeader();
            columnCode.Text = xml.Element("S28").Value;
            ColumnHeader columnCompany = new ColumnHeader();
            columnCompany.Text = xml.Element("S29").Value;
            list.Columns.Add(columnCode);
            list.Columns.Add(columnCompany);
            foreach (String code in Nitro.Estructuras.makerCode.Keys)
            {
                list.Items.Add(code);
                list.Items[list.Items.Count - 1].SubItems.Add(Nitro.Estructuras.makerCode[code]);
            }
            list.AutoResizeColumns(ColumnHeaderAutoResizeStyle.ColumnContent);
            list.AutoResizeColumn(0, ColumnHeaderAutoResizeStyle.HeaderSize);
            ven.Controls.Add(list);

            ven.Text = xml.Element("S2A").Value;
            ven.Show();
        }
开发者ID:MetLob,项目名称:tinke,代码行数:35,代码来源:EditRomInfo.cs

示例5: AutoResizeListViewColumn

        /// <summary>
        /// Automatics the resize ListView column.
        /// </summary>
        /// <param name="lv">The lv.</param>
        /// <param name="ch">The ch.</param>
        private static void AutoResizeListViewColumn(ListView lv, ColumnHeader ch)
        {
            var headerWidth = ch.Text.Length;

            var changeHeader = true;

            foreach (ListViewItem LVI in lv.Items)
            {
                EnsureSubItemCount(lv, LVI);
                var temp = ch.Index == 0 ? LVI.Text.Length : LVI.SubItems[ch.Index].Text.Length;

                if (temp > headerWidth)
                {
                    changeHeader = false;
                    break;
                }
            }

            lv.AutoResizeColumn(ch.Index,
                changeHeader
                    ? ColumnHeaderAutoResizeStyle.HeaderSize
                    : ColumnHeaderAutoResizeStyle.ColumnContent);
        }
开发者ID:andreigec,项目名称:ANDREICSLIB,代码行数:28,代码来源:ListViewExtras.cs


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