How do you know the name or index of the checkedListBox?



  • How do you know the name or index of the list? CheckedListBox When am I clicking on one of the list elements?

    And if you can find out about the element that's not just in it. CheckListBoxbut it's acceptable. Label? I want to make a button that removes this chosen element from my list.

    введите сюда описание изображения

    private void button3_Click(object sender, EventArgs e)
    {
    
    bool relay = false;
    int nolIndex = 0;
    int k3 = 0;
    GraphPane pane = zedGraph.GraphPane;
    for (int i = 0; i < Program.axisList[0].sumAxis; i++)
    {
        if (Program.axisList[i].sumPoints == 0)
            nolIndex = i;
    
    }
    
    if (nolIndex != 0)
        relay = true;
    
    for (int i = 0; i < checkedListBox1.Items.Count; i++)
    {
    
        if ((checkedListBox1.CheckOnClick == true)||(checkedListBox1.CheckOnClick == false))&&(номер по которому кликнул)
        {
            if (i < nolIndex)
            {
                k3 = 0;
                checkedListBox1.Items.RemoveAt(i+k3);
                pane.CurveList[i + k3].IsVisible = false;
                pane.YAxisList[i + k3].IsVisible = false;
                labelOfAxis[i + k3].Visible = false;
                pane.XAxis.IsVisible = false;
            }
            else if ((i == nolIndex) && (i != 0))
            {
                checkedListBox1.Items.RemoveAt(i + k3);
                pane.CurveList[i + 1].IsVisible = false;
                pane.YAxisList[i + 1].IsVisible = false;
                labelOfAxis[i + 1].Visible = false;
                pane.XAxis.IsVisible = false;
            }
            else
            {
                if (relay == true)
                    k3 = 1;
                else
                    k3 = 0;
                checkedListBox1.Items.RemoveAt(i + k3);
                pane.CurveList[i + k3].IsVisible = false;
                pane.YAxisList[i + k3].IsVisible = false;
                labelOfAxis[i + k3].Visible = false;
                pane.XAxis.IsVisible = false;
            }
        }
    
    }
    k3 = 0;
    

    }



  • Ooh. CheckedListBox There is a characteristic. CheckedItems (LAUGHS) SelectedItems) - it returns the collection of observed elements in this management element CheckedListBox♪ Read. https://msdn.microsoft.com/ru-ru/library/system.windows.forms.checkedlistbox(v=vs.110).aspx

    To track changes in the selection of elements, you need to process the event. ItemCheck - The case shall be submitted to the processor ItemCheckEventArgswhich you can find out what element was marked (or was removed). https://msdn.microsoft.com/ru-ru/library/system.windows.forms.checkedlistbox.itemcheck(v=vs.110).aspx




Suggested Topics

  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2