• <bdo id='0fO76'></bdo><ul id='0fO76'></ul>
      <i id='0fO76'><tr id='0fO76'><dt id='0fO76'><q id='0fO76'><span id='0fO76'><b id='0fO76'><form id='0fO76'><ins id='0fO76'></ins><ul id='0fO76'></ul><sub id='0fO76'></sub></form><legend id='0fO76'></legend><bdo id='0fO76'><pre id='0fO76'><center id='0fO76'></center></pre></bdo></b><th id='0fO76'></th></span></q></dt></tr></i><div id='0fO76'><tfoot id='0fO76'></tfoot><dl id='0fO76'><fieldset id='0fO76'></fieldset></dl></div>

      <small id='0fO76'></small><noframes id='0fO76'>

    1. <legend id='0fO76'><style id='0fO76'><dir id='0fO76'><q id='0fO76'></q></dir></style></legend>
      <tfoot id='0fO76'></tfoot>

      1. 如何将图像添加到 System.Windows.Forms.ListBox?

        How do add image to System.Windows.Forms.ListBox?(如何将图像添加到 System.Windows.Forms.ListBox?)
          <tbody id='yXCNv'></tbody>

              • <bdo id='yXCNv'></bdo><ul id='yXCNv'></ul>

                <small id='yXCNv'></small><noframes id='yXCNv'>

                  <tfoot id='yXCNv'></tfoot>
                  <i id='yXCNv'><tr id='yXCNv'><dt id='yXCNv'><q id='yXCNv'><span id='yXCNv'><b id='yXCNv'><form id='yXCNv'><ins id='yXCNv'></ins><ul id='yXCNv'></ul><sub id='yXCNv'></sub></form><legend id='yXCNv'></legend><bdo id='yXCNv'><pre id='yXCNv'><center id='yXCNv'></center></pre></bdo></b><th id='yXCNv'></th></span></q></dt></tr></i><div id='yXCNv'><tfoot id='yXCNv'></tfoot><dl id='yXCNv'><fieldset id='yXCNv'></fieldset></dl></div>
                • <legend id='yXCNv'><style id='yXCNv'><dir id='yXCNv'><q id='yXCNv'></q></dir></style></legend>
                • 本文介绍了如何将图像添加到 System.Windows.Forms.ListBox?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着跟版网的小编来一起学习吧!

                  问题描述

                  我正在使用 C# 开发聊天程序,并使用 ListBox 管理昵称列表.但是,客户有昵称和状态(在线,离开)

                  I'm developing chatting program using C# and I manage nickname list using ListBox. But, client have nickname, and state (online, away)

                  所以,为了管理状态,我想将图像(在线-绿色圆圈,离开-红色圆圈)添加到ListBox(这是我的想法)

                  So, in order to manage the state, I want to add image (online - green circle, away - red circle) to ListBox (it is my idea)

                  如何将图像添加到 ListBox?请帮帮我.

                  How can add image to ListBox? Please help me.

                  谢谢.

                  推荐答案

                  你不能在 ListBox 中轻松做到这一点.使用 Graphics 绘制它们一点也不容易.我建议改用 DataGridView o ListView 控件.

                  You can't do that easily in the ListBox. And drawing them using Graphics is not easy at all. I suggest using a DataGridView o ListView control instead.

                  结果:

                  DataGridView:有一个名为 DataGridViewImageColumn 的 ColumnType,您可以使用它来显示您的状态图标.

                  DataGridView: There's a ColumnType called DataGridViewImageColumn that you can use to show your status icon.

                  public void FillDataGridView()
                  {
                      //images
                      var greenImg = Resources.green;
                      var redImg = Resources.red;
                      var yellowImg = Resources.yellow;
                  
                      dataGridView1.Rows.Add(new object[] {"Vland", greenImg});
                      dataGridView1.Rows.Add(new object[] {"John", yellowImg });
                      dataGridView1.Rows.Add(new object[] {"Paul", greenImg});
                      dataGridView1.Rows.Add(new object[] {"George", redImg});
                      dataGridView1.Rows.Add(new object[] {"Ringo", redImg });
                  }
                  

                  如何:在Windows 窗体 DataGridView 控件的单元格

                  ListView:可以添加文字+图片组成的项目.如果您使用 ListView,则需要将 imageList 组件添加到您的表单(其中包含您的图像)并调用它们的 imageKey 值,如示例中所示

                  ListView: can add items composed by text + image. If you use the ListView, you need to add an imageList component to your form (with your images in it) and call their imageKey value like shown in the example

                  public void fillListView()
                  {
                      listView1.SmallImageList = imageList1;
                  
                      listView1.Items.Add("BombPenguin", "green");
                      listView1.Items.Add("Vland", "yellow");
                      listView1.Items.Add("John", "red");
                      listView1.Items.Add("Paul", "green");
                      listView1.Items.Add("Ringo", "red");
                  }
                  

                  如何:显示 Windows 窗体 ListView 的图标控制

                  这篇关于如何将图像添加到 System.Windows.Forms.ListBox?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!

                  本站部分内容来源互联网,如果有图片或者内容侵犯了您的权益,请联系我们,我们会在确认后第一时间进行删除!

                  相关文档推荐

                  Populate ListBox with a IEnumrable on another thread (winforms)(在另一个线程(winforms)上使用 IEnumrable 填充 ListBox)
                  listbox selected item give me quot; System.Data.DataRowViewquot; , C# winforms(列表框选择的项目给我quot;System.Data.DataRowView, C# Winforms)
                  Cannot remove items from ListBox(无法从列表框中删除项目)
                  Preventing ListBox scrolling to top when updated(更新时防止列表框滚动到顶部)
                  Drag and drop from list to canvas on windows phone with MVVM(使用 MVVM 在 Windows 手机上从列表拖放到画布)
                  Deselection on a WPF listbox with extended selection mode(具有扩展选择模式的 WPF 列表框上的取消选择)

                  <small id='NXPFA'></small><noframes id='NXPFA'>

                    <bdo id='NXPFA'></bdo><ul id='NXPFA'></ul>

                            <tbody id='NXPFA'></tbody>

                        • <tfoot id='NXPFA'></tfoot>
                          <legend id='NXPFA'><style id='NXPFA'><dir id='NXPFA'><q id='NXPFA'></q></dir></style></legend>

                          1. <i id='NXPFA'><tr id='NXPFA'><dt id='NXPFA'><q id='NXPFA'><span id='NXPFA'><b id='NXPFA'><form id='NXPFA'><ins id='NXPFA'></ins><ul id='NXPFA'></ul><sub id='NXPFA'></sub></form><legend id='NXPFA'></legend><bdo id='NXPFA'><pre id='NXPFA'><center id='NXPFA'></center></pre></bdo></b><th id='NXPFA'></th></span></q></dt></tr></i><div id='NXPFA'><tfoot id='NXPFA'></tfoot><dl id='NXPFA'><fieldset id='NXPFA'></fieldset></dl></div>