title: Is there a simple method to get coordinates of a particular item in a checkedlistbox?
body: <p>I am making a simple class extending CheckedListBox that just adds a small textbox to the right of an item when it is checked. My issue is finding a good way to place the box at the correct location. </p>
  
  <p>I had initially though I could use the Controls.Find() along with the ItemCheckEventArgs index to get the coordinates of the checkbox in question, and move to the right edge of the column from there. However, that did not work, and a brief look through the CheckedListBox class seemed to show that it does not actually contain any CheckBox controls, but merely draws images of them.</p>
  
  <p>I then came up with the following method:</p>
  
  <pre><code>void CreateAmountBox(int index)
      {
          int itemsPerCol = Height/ItemHeight;
          int x = GetColumn(index, itemsPerCol)*ColumnWidth - boxWidth;
          int y = (index % itemsPerCol)*ItemHeight - offset;
  
          System.Windows.Forms.TextBox NewAmountTextBox = new System.Windows.Forms.TextBox();
          NewAmountTextBox.Location = new System.Drawing.Point(x, y);
          NewAmountTextBox.Name = Items[index] + "Amount";
          NewAmountTextBox.Size = new System.Drawing.Size(20, boxWidth);
          Controls.Add(NewAmountTextBox);
      }
  </code></pre>
  
  <p>where GetColumn(...) returns the column of the given index (from the CheckEventArgs). This works, but it feels like a hack and is not very readable.</p>
  
  <p>Two other ideas I thought of:</p>
  
  <p>1) I could just create all the TextBoxes at the start, and simply hide them until they are needed. Controls like these are all created dynamically throughout the rest of the program however, and I don't want these ones to be the odd exception. It also means that some more functionality needs to be added for cases when an item is added or removed.</p>
  
  <p>2) I could use mouse position, which of course won't work if the input is via keyboard. I don't anticipate it ever being so, but best not to leave that possibility.</p>
  
  <p>With some googling, the only other way I found of possibly doing this was using the ListBoxItem and TranslatePoint method, but I haven't gotten that to work, and I'm unsure as to whether it even can with a CheckedListBox instead of a ListBox.</p>
  
  <p>So, is there a simple way of finding the x and y of the checked item that I don't know of? Or am I limited to simply extracting the x and y declarations above into a method and leaving it there?</p>