473,383 Members | 1,879 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,383 software developers and data experts.

Two lines text of item in MenuItem

10
I added an item to MenuItem control, and I want its title/text to be written on two lines.
e.g.:
Expand|Select|Wrap|Line Numbers
  1.             MainMenu mm = new MainMenu();
  2.             MenuItem mi = new MenuItem();
  3.             mi.Text = "file";
  4.             mi.MenuItems.Add("open"+Environment .NewLine +"file");
  5.             mm.MenuItems.Add(mi);
  6.             this.Menu = mm;
That should displays the item on two lines:
open
file


but, it doesn't work, and the item's text is displayed on one line:
openfile

Does anyone have an idea how can I do that?

Thanks.
May 19 '11 #1
2 2359
GaryTexmo
1,501 Expert 1GB
Hmm you know, I'm not sure if you can. My best guess would have been throwing an Environment.NewLine in there as well. That said, when I do it I actually see the square characters for the "\r\n" instead of nothing like you do. I also tried the designer with the usual ctrl+enter or alt+enter to see if I could force one in there and no dice.

Now, interestingly enough, if you check the text of the menu item you created it still retains the newline character (do a console.writeline on it). This leads me to believe that the paint method for a menu item is doing something specific to make sure it doesn't have text that's more than one line. Maybe this is something Microsoft wants to enforce in their application look and feel? When I think about it, I don't think I've ever seen a menu selection that went over two lines like that.

That being said, since the menu item does retain the newline character in it's text, perhaps you can create a class inheriting from menu item and override the paint method to draw it in your own way? It might take a bit of work, but it's something that might be worth looking into. Play around with it and see what happens?
May 19 '11 #2
st mnmn
10
OK, It seems you're right. the menu item retains the new line character in it's text.
but, what should I write in the paint method?
Can you direct me?
May 23 '11 #3

Sign in to post your reply or Sign up for a free account.

Similar topics

4
by: Peter Otten | last post by:
Is there a way to limit both width and height of a canvas text item? My current workaround seems clumsy: import Tkinter as tk root = tk.Tk() canvas = tk.Canvas(root, width=400, height=200,...
1
by: BC | last post by:
Hello, I successfully display an add-in menu. However, when I try to hook the message item to the event handler, I receive this compiler error message: (291): Method...
2
by: Kel Good | last post by:
Hello, I am binding a custom IList object to a DataList that I am using for a web menu. The items in the custom IList have properties that allow me to dynamically define how my menu behaves. My...
6
by: George | last post by:
Hi all, How can I get the value stored from the selected item and subitems of a listview? Thanks in advance, George
3
by: ad | last post by:
I have set a TextBox to MultiLines and set the rows to 10. I assigned the Text of the TextBox some lins of text at desgin time, but only the first line remain in the TextBox. How can I assign...
1
by: romi | last post by:
hello all, i have made a tab canvas of 3 tab page.In all tab pages, there r some text item.i have made it through layout editor.now i want to save all text item values in table(database) like...
2
by: flyzone | last post by:
Goodmorning people :) I have just started to learn this language and i have a logical problem. I need to write a program to parse various file of text. Here two sample: --------------- trial...
0
by: write2jagdeep | last post by:
i Want to change color of text item when got focus in forms builber d2k and revert that color when lost focus. Pls anser it urgently.
7
vikas251074
by: vikas251074 | last post by:
Can I get automatic focus on first text item just after running programme? Because when I run the programme, there is no focus on any text item at the first instant. I have to use mouse to go to...
4
by: Mudcat | last post by:
I've tried quite a few things to get this correct but have hit a couple of sticking points that I can't figure out. I need to ge the Text box to function like the 'wraplength' option in a Label. ...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
by: ryjfgjl | last post by:
In our work, we often need to import Excel data into databases (such as MySQL, SQL Server, Oracle) for data analysis and processing. Usually, we use database tools like Navicat or the Excel import...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.