The use of C# control ListView (including Halcon parameter conversion)

The use of C# control ListView (including Halcon parameter conversion)

In this summary part about the use of the ListView control:
Part 1:
  Complete the specific operation steps of the ListView control as shown in the figure:
Insert picture description here(1) After inserting the ListView control, click the arrow in the upper right corner of the control, and modify the view option in the drop-down list to Details, as shown in Figure
Insert picture description here(2), after modifying the view options, click Edit Columns , add the number of columns in the pop-up dialog box, and then modify the Text of each column. You can also modify the width of each column, as shown in the figure: The
Insert picture description here

second part
  is above The relevant code for displaying data in the completed ListView control:

         //ObjectResult 是创建的一个类
        public void ShowObjectRes(ObjectResult res)
        {
    
    
            //获取列表的行数
            int count = listView1.Items.Count + 1;//+1是让第一列序号的值从1开始
            //实例化一个ListView的项
            ListViewItem lv = new ListViewItem();

            lv.Text = count.ToString();
            //向子项中添加数据
            lv.SubItems.Add(res.Tx.ToString());
            lv.SubItems.Add(res.Ty.ToString());
            lv.SubItems.Add(res.Tz.ToString());
            lv.SubItems.Add(res.Alpha.ToString("0.00"));//保留两位小数
            lv.SubItems.Add(res.Beta.ToString("0.00"));
            lv.SubItems.Add(res.Gamma.ToString("0.00"));
            
            listView1.Items.Add(lv);
        }



The third part (the display of Halcon parameters in ListView)
  After Halcon is converted to C#, if you want to display the parameters in ListView, you need to convert them. The specific explanation is as follows:
  If the Halcon parameter is of double type, To display it directly in double type, then it needs to be converted like this:

                                              hv_Angle.D

  If the Halcon parameter is a double type, if you want to convert it to an int type, you need to convert it like this:

                                              (int)hv_Row.D

Guess you like

Origin blog.csdn.net/Kevin_Sun777/article/details/108880412