4

so I'm very confused here. I want to make my multilined CheckedListBox to be sorted horizontally. I've done some research and it is all leading to the RepeatDirection property. Example in the MSDN

But I don't have a web page and I don't know any XML. Can't I just somehow use this property for the CheckedListBox Control? The MSDN people say it is already a property of that Control as they simply have written:

public virtual RepeatDirection RepeatDirection { get; set; }

I just can't seem to understand how to implement this in my code! Thanks in advance.

EDIT: I don't have a web form! It is a System.Windows.Formsproject. I just tagged web-controls because the RepeatDirection property seems to exist in the System.Web.UI.WebControls namespace.

  • Of course you can. In your `.aspx` markup page, where you have defined your `` simply set `RepeatDirection` property. For example it would go like this ``. You can see full example [here](https://msdn.microsoft.com/en-us/library/system.web.ui.webcontrols.checkboxlist.repeatdirection(v=vs.110).aspx). – Michael Feb 18 '15 at 09:03
  • @Michael What is a ".aspx markup page" ? My code is in C# and I can't find any .aspx if I search the solution explorer! – RegisteredFreak Feb 18 '15 at 09:49
  • Yeah, if you're using win forms then you can't use `RepeatDirection` on your control, as you mentioned in your post that is part of `System.Web.UI.WebControls` namespace. What you can try thou is to set `MultiColumn=true` on your `CheckedBoxList` control and try to adjust width of your control to have it shown its items horizontally. – Michael Feb 18 '15 at 10:37
  • @Michael I already did that. My CheckedListBox is already 4 rows long. [(1) (4) (7)] [(2) (5) (8)] [(3) (6) (9)] The only stupid thing is that I can't sort its elements like this: [(1) (2) (3)] [(4) (5) (6)] [(7) (8) (9)] – RegisteredFreak Feb 18 '15 at 11:19
  • The text editor on this website is so.. smart. Anyway what I'm trying to achieve is to get the numbers to start at the first row like 1,2,3 and the second 4,5,6 and so on and so forth. – RegisteredFreak Feb 18 '15 at 11:29
  • __If__ you can make sure that __no scrollbars__ are needed you can add the items in the order you want. – TaW Feb 19 '15 at 20:24

1 Answers1

1

Short answer: You can't. ListBox as implemented in the Windows Forms does not support repeating horizontally. You aren't using the web version of the control, so you can't use the web version's options.

If you still need to display your options horizontally you will need to use a different control. Depending on your requirements, a DataGridView should be able to do what you are wanting, with some tweaking.

Tim
  • 2,878
  • 1
  • 14
  • 19