checkedlistbox highlight and spacing
-
Hi, I am still fairly new to C# and I am having some problems that I hope I can find an answer to soon. I am working on a program that reads in an XML file and then creates a bunch of checkboxes based off of what it finds in the file. Seeing how the number of checkboxes is dependent on what is in the XML, I decided to go with a checkedlistbox. I have modified the background color of the control so it looks like a normal grouping of checkboxes. The two problems I am having are: 1) When you check a checkbox or uncheck it, the line is highlighted. I have looked for a way to change the highlight color but have not been able to so far. I want it to behave more like a checkbox so no hightlight. 2) I would like to increase the spacing between the items a bit. Again I have not been able to find a way to do this with the properties or events. Thank you in advance. I hope it is not to much of an obvious solution as I have been ripping my hair out on this for several days. Sean
-
Hi, I am still fairly new to C# and I am having some problems that I hope I can find an answer to soon. I am working on a program that reads in an XML file and then creates a bunch of checkboxes based off of what it finds in the file. Seeing how the number of checkboxes is dependent on what is in the XML, I decided to go with a checkedlistbox. I have modified the background color of the control so it looks like a normal grouping of checkboxes. The two problems I am having are: 1) When you check a checkbox or uncheck it, the line is highlighted. I have looked for a way to change the highlight color but have not been able to so far. I want it to behave more like a checkbox so no hightlight. 2) I would like to increase the spacing between the items a bit. Again I have not been able to find a way to do this with the properties or events. Thank you in advance. I hope it is not to much of an obvious solution as I have been ripping my hair out on this for several days. Sean
This sounds like an owner-drawn listbox, here is a good tutorial: http://www.codeproject.com/books/1930110286\_10.asp -- modified at 14:53 Friday 11th November, 2005 Basically you have to capture the draw event, measure the rectange and set its size using the measureItem event (to modify the vertical distance) To change the highlighted text you set the solidbrush color to your background color to hide the highlight. SystemColors.Highlight comes from the OS and I don't think you can change it programmatically (at least easily) Horizontal spacing is easy, just change the column width property