private void Form1_SizeChanged(object sender, EventArgs e) If you have to change the layout style, swap the right-aligned items so that they appear in the correct order in either layout style. Track the SizeChanged event to determine if you need Flow or StackWithOverflow based on the width of all menu items and the available width of the window. The solution to your problem is in two parts: If you are using Flow alignment style, then the items will always flow from left-to-right.Īlso, when you right-align items in StackWithOverflow layout style, the item flow from the outside in, so if your original layout is 1 2 3 4 5, your right-aligned items would be 1 2 3 5 4. However, right alignment only applies in the StackWithOverflow layout styles. I had the same problem in VS 2008.In order to right-align some menu items, you need to set the item's Alignment value to Right. So if someone can find a possible logical reason for this to happen I would always appreciate some extra explanation, but in the meantime, I will think of this as a kind of a weird little bug. As you can see it was pretty simple, although I have no idea how did that line deleted itself. I hope this may be useful for someone, or at least give an idea of what to do when such items disappear from the designer view. Although my problem is resolved, I'm still wondering why would that line have gone away when I was messing with the resources. That apparently put all my menu items inside my menuStrip again, in the designer view. I notice that there was an essential line missing right at the beggining, the one that misteriously disappeared: In my I had this code for the menuStrip: Anyway, I might have found an apparent working solution, that afterwards was easily discoverable. Well thanks for your reply, as it sure gave me a starting point to begin discovering for a solution, but that may not be the case. I don't know if this is some kind of bug, but I thought I could have some feedback from you first. If something is unclear to you let me know. If I add this piece of code in the Form_Load() event, all my menu items will reappear, but only at runtime, so you can see that is everything normal except that I just can't see them at design time anymore. To give you a more concrete example of the situation, take this code for example: The only strange thing in this is that the code of the menu items is still in the, other than that, it's all normal.Įven if you did not understand something about the 'recreation' of this situation, just focus on the actual issue, that is, I virtually have all my ToolStripMenuItems (even in the object list, in the properties window), but my MenuStrip somehow is not linked to them anymore. When I came back to the designer view the menuStrip was there, but without any ToolStripMenuItems. Then I went to the 'image' property of my picturebox (the one that was using the image that I moved) and I couldn't select any other resource as its image, neither select the 'none' option.Īll this may not be quite relevant, or may be confusing, but anyway, I then moved back the image to its initial location, so I would be able to select 'none' as the picturebox's image, BUT after all this confusion with a simple resource image, I then ran my program and suddenly it was like my menu was totally gone. I then received some notification about the actual resource not being found inside the folder, and I removed the resource (in the resource panel of the 'My Project' properties) and dragged the same image (that I had placed in another folder) again to my project's resources. In the Solution Explorer, I have a Resources folder, with some images (icons for the menu, etc), and the last thing I remember having done before the menu items disappeared was only that I moved one of the images to a folder (a folder inside the resources folder, through the Solution Explorer). And after that, they were gone in the actual designer view too.Īs this is the second time this is happening to my application, I think I may have noticed some kind of pattern, that is related to the resources. I was developing my application like I normally do, but a while ago, when I was running the application to preview it (F5/debug), all my menu items were gone. Hello, I'm having a serious issue with the MenuStrip, and this is happening already for the second time.
0 Comments
Leave a Reply. |