Windows mobile button text new line - c#

I need to have new line in button.text in Windows Mobile 6,5. I have following code
this.button1.Text = "some \r\n one";
Even if I try
this.button1.Text = "some" + Enviroment.NewLine + "one";
I can't see second line in my button. I see only some. I tried to resize my button but It doesn't effect on it.
Any Ideas?
Thanks

The Button control does not support Multiline input.

Compact Framework does not support multiline text (BS_MULTILINE) although it is supported by C/C++: http://msdn.microsoft.com/en-us/library/windows/desktop/bb775951%28v=vs.85%29.aspx.
You may use this solution: http://social.msdn.microsoft.com/Forums/en-US/vssmartdevicesvbcs/thread/67664186-e61c-4510-8414-939fce37a30c

The better way is to use a image in which you have the TEXT.
Instead of the button use a picture box and add the codes to the click event of picture box.

Related

Hide button text behind button image

Is there any method to hide a button text behind button image like bring to front or send to back option?
I only need to hide or show button image only as I have a code that coverts the original text CloseButton.text = "&Close"; to CloseButton.Text = "&Cancel";
to perform another command so I can't use CloseButton.Text = "";.
Tried this link - WinForms button with image and text but my button size is too small that it would only show the text and not the image no matter how I mix and match TextAlign and ImageAlign.
Any help is much appreciated. Thanks in advance.
Sample Button Size below:
Check this
Place Textbox in Button and set textbox.visible=false method
Is there any method to hide a button text behind button image like
bring to front or send to back option?
There is no such built in but you can simply clear out the text on click event of the controls. Example: if you have radio buttons for send to back then on click of that clear out the control text saying controlId.Text = string.Empty
As #Rotem posted in the comments.
Have your code behind use the Tag property rather than Text. Easiest way out is using properties for what they were made for.
Instead of using CloseButton.text = "&Close"; I changed it to CloseButton.Tag = "&Close"; and made my code worked around it to have the same function without placing an actual Text in my Buttons. Credit this asnwer to #Rotem. Thanks.

Message Box yesnoButtons in windows phone 7.5

In window phone 7.5 . I want to use yes no buttons in message box . But there is no option for yes no buttons in message box. How can i use with yes no buttons or other alternate to show caption (OK =yes and cancel =no)
Please help me.
Thanks in advance.
You can use the Coding4Fun MessagePrompt to create Yes/No message with custom buttons in this way:
MessagePrompt messagePrompt = new MessagePrompt();
messagePrompt.Message = "Some Message.";
Button yesButton = new Button() { Content = "Yes" };
yesButton .Click += new RoutedEventHandler(yesButton _Click);
Button noButton = new Button() { Content = "No" };
noButton .Click += new RoutedEventHandler(noButton _Click);
messagePrompt.ActionPopUpButtons.Add(noButton);
messagePrompt.ActionPopUpButtons.Add(yesButton );
messagePrompt.Show();
Another option is to use the Guide class from the XNA framework. There is a BeginShowMessageBox method giving you the option to pass in whatever strings you wish for the buttons.
The other option is to use MessagePrompt from Coding4fun toolkit and customize according to your needs
Yes, the problem with WP MessageBox is that it only supports the OK and OKCancel MessageBoxButton, which means that you’re limited to either an ok button or an ok and a cancel button. The YesNo and YesNoCancel enumeration values are not supported.
Basically you can try to display a semi-transparent blanking layer over the page content, and then display a custom message box on top of that. Here, you can find a complete sample.
Another option is to use a custom library like Windows Phone Assets.

Similar to alt tag in WinForms controls

Maybe that's a noob question but is there a way to have an yellow tooltip alike web alt while using web browser in winform application controls such as checkBox or Button ?
ToolTip tooltip = new ToolTip();
tooltip.SetToolTip(checkBox, "A tooltip on my checkBox");
tooltip.SetToolTip(button, "A tooltip on my button");
There's a tooltip you can add to buttons etc. in WinForms - is that what you mean?
If so there's a tutorial on Code Project. Basically you need this code:
private System.WinForms.ToolTip m_wndToolTip;
this.m_wndToolTip = new System.WinForms.ToolTip (this.components);
m_wndToolTip.SetToolTip (PictureButton, "Click Me!");
m_wndToolTip.SetToolTip (m_wndIntTextBox, "Enter Integer data type value.");
If you press F4 you will get the controls options in that go to the bottom and you will find a tooltip option and give your message there and it appears when you run the application and you'll find the tooltip when you hover the mouse over the button or what ever it might be.
You want a tooltip. See this MSDN article.

How to change the background color of button in windows phone application?

I am developing window phone 7 application in C# & silverlight 4. I am new to the silverlight.I have two buttons in my application for different purposes. I want to change the color of the button dynamically when the button gets clicked. So I am using the following code
IncomeButton.Background = new SolidColorBrush(Colors.Red);
But it is not working. Can you please provide me any code or link through which I can resolve the above issue ? If I am doing anything wrong then please guide me.
Changing the styling of a button from it's own click event comes with a catch. Peter elaborates here.
Why can't I change the Background of my Button on a Click event? - Peter Torr's Blog
You can simply execute IncomeButton.UpdateLayout() after changing button's color.
I also ran into that "simple" problem. Instead of using Peter's "button styling change" thing, I simply placed a rectangle below the button and changed it's color with the Rectangle.Fill property in the Click event of the button. Works fine for me.

.NET Label.TextAlign seems not to work

I have a label that I want to right align to be able to place aligned to a text box.
The Designer in Visual Studio 2010 Express have generated this code for me
this.lblAddData.AutoSize = true;
this.lblAddData.Location = new System.Drawing.Point(167, 452);
this.lblAddData.Name = "lblAddData";
this.lblAddData.Size = new System.Drawing.Size(25, 14);
this.lblAddData.TabIndex = 5;
this.lblAddData.Text = "text";
this.lblAddData.TextAlign = System.Drawing.ContentAlignment.MiddleRight;
[text][textbox]
In the code I change the text programmaticly
lblAddData.Text = "a very long text";
but the text is hiding behind the texbox that I have placed next to the label on the
right side.
[a ver][textbox]
Have someone experienced the same problem before?
I know it is missing information so ask me if you need more info.
Best Regards
Görgen
Well, I spotted the error myself; AutoSize was set to true, that is default behavour
this.lblAddData.AutoSize = true;
When I changed this to false it worked as I assumed it should.
The TextAlign property controls how the text is aligned within the label:
Gets or sets the alignment of text in the label.
If you change the length of the text you need recalculate the Location of the label which is always top left.
I've found this Code Project article which, while probably over the top for what you want, states:
Moreover, if you are going to change the label text (e.g., when localizing the application) or text alignment, you'll have to resize/reposition controls. Therefore, I have created this simple label that takes care of such details.
(my bold)
So you could use the same algorithm to reposition your label.

Categories

Resources