I want to show a MessageBox in a VB.NET application that has special markup for its text. More specifically, I want to display an unordered list. I tried doing it by wrapping the text in HTML tags (which Java Swing supports for example, if I'm not mistaken) and working with <ul> and <li>. This did not work. I can't find anything on the net about it either...
The textbox is used in a normal Windows forms application.
Does anyone know how to do it without creating a completely custom messagebox class?
As Hans Passant says, this is not possible with the default MessageBox in VB.NET.
Related
How can I return a message box with functioning HTML tags using VBA?
example
dim mtext as string
mtext = "<em>hello</em> <br> world"
msgbox mtext
You don't. The MsgBox function is just a thin wrapper over a Win32 API function, and that function doesn't deal with HTML input. HTML is for web browsers, not desktop applications.
The closest thing you could get is a custom UserForm with a RichTextBox control, but that's OCX tech developped for Visual Basic 6.0 and probably won't work on x64 machines, not to mention that it will definitely break down if you need to distribute your macro to users that don't have the OCX on their machines.
A better alternative could be to make a COM-visible class library in your favorite .NET language (C#, VB.NET), and expose a custom MessageBox function that displays a WinForms dialog featuring a System.Windows.Forms.RichTextBox control that can process and display RTF formatted text.
You then need to distribute and register your COM type library to your users.
In other words, it can be done - it only depends how badly you want it.
I would custom design a form and then have the text set based on your needs specifically. May I ask why you are wanting to use HTML codes? Cause, it may be simple enough to create your own library/class to handle the processing, before pushing to a rich text box. However, the Rich Text Box is only going to be in VB, like using VB Studio Express. With VBA, you're sort of stuck...sorry.
Good day everyone,
I just want to ask how to do this on vb.net using vs2010
It's like a label(i'm not sure if it's really a label), like this
and when you put the cursor on it, it will show a "button"?.. like this,
The Control to create the menu is called a toolstrip:
Tutorial for this:
Tooltrips - basics
.Net Heaven
To add those labels when hovering above it, you must use a tooltip.
There is a built in option (that doesn't require an extra control)
Tutorial: MSDN- How to: Use ToolTips in ToolStrip Controls
But you could implement the behavior yourself using the control "tooltip".
Here's some tutorials on how to implement it:
Tooltips
.Net Heaven
Dotnetperls
Enjoy
Is it possible to have 2 areas of text in one cell such that each can have a different color? You can do this in crystal reports but I cannot see a way to do this in ReportViewer. What it is doing is essentially highlighting an important text fragment if it appears in a cell description to draw the users attention. I am fairly new to reportviewer so it for now I am assuming it's my lack of knowledge that is making this difficult. I am using VS2010.
Thanks.
Turns out VicarlnATutu wasn't quite right.
You can do this, but only if you are using VS2010 (which I am) because it includes the new SSRS rendering engine for SQL-Server 2008. This allows you to put some basic HTML into a field and have multiple formats in one cell. For more info see below:
http://msdn.microsoft.com/en-us/library/cc645967.aspx
http://msdn.microsoft.com/en-us/library/cc627491.aspx
One thing that tripped me up is what they call a 'placeholder' in the MS documentation is the little bit of text inside the textbox control that shows up by default. You can select two different things on the control in VS2010. One is the textbox itself. Right clicking on the textbox gives you 'text box properties'. The other thing you can select is the default text INSIDE the textbox. Right clicking on this 'placeholder' text gives you a different context menu where you can select 'placeholder properties'. This is where you can change the cell to accept HTML.
No, unfortunately not. I don't know if there are custom controls out there for ReportViewer, but the built-in TextBox only supports setting color (be it Foreground or Background) for the entire thing.
ah, good to know. kind of a unintuitive way to tell a TextBox to display HTML, but nice to know that you can!
I'm a noob to VB.NET and I was wondering how to make something you type into a textbox on the application type that text into a website textbox and submit whats in the textbox by pressing a button? I am using visual studio 2008.
That is a little tricky to do, but it is possible. However, without more details on the specific browser or what you are trying to copy over, you aren't going to get a lot of answers on here.
Better Suggestion: Have you considered instead of trying to control the browser via "voodoo", that you might just have your VB.NET application submit the form/request directly to the web server and cut out the middle-man (the browser)?
I'm assuming you're trying to POST data to a web form from some other application. Check this out; it's in C# but you can translate it to VB.NET. It uses a WebBrowser control and the SetAttribute method to set input values on the web form.
// C#
WebBrowser browser;
...
browser.Document.GetElementById("username").SetAttribute("value", "MyUsername");
...
form.InvokeMember("submit");
OKay, I'm from a PHP background, but I've just been tasked with developing some custom Web Parts in SharePoint. I've figured out how to create and deploy a basic "Hello world" web part in VB. Okay so far.
What I'm stuck on is a really basic, stupid point - how the hell do I lay out things in a VB web part?
For an example, here's a label and a textbox:
protected overrides sub createchildcontrols()
mybase.createchildcontrols
dim mylabel as new label
dim mytextbox as new textbox
mylabel.text ="My label text"
mytextbox.text ="My textbox"
me.controls.add(mylabel)
me.controls.add(mytextbox)
How would I, for example, get mylabel and my textbox to appear on different lines, rather than running one after the other as they do now? In PHP I'd just wrap them in some top break them onto differnt lines, but how do I do it here?
There are a number of ways to go about it. The easiest, if you really just want the controls to appear on different lines would be to add an ASP.net LiteralControl with a BR tag between them.
Aside from that, you can always use the ASP.net formatting controls, like Table to break your controls into sections for output.
Additionaly, everything that derives from WebControl has an Attribues and CssClass property for setting formatting based on style-sheets you can use.
The last method, and the most customizable, but hardest to maintain and change, would be to override the webpart's Render method and generate your HTML completely by hand in the WebPart.
Alternately, you could scrap this altogether, and employ the SmartPart to develop ASP.net user controls for use inside of SharePoint, giving you the options to use the Visual Studio designer tools to layout your controls on the form.
You should override the Render() method. By default this method just renders all the child controls you have added in the CreateChildControls() method, but overriding it lets you write additional HTML elements around the controls.
I usually code in C#, but I think the following example should work in VB:
Protected Overrides Sub Render(ByVal writer As System.Web.UI.HtmlTextWriter)
writer.Write("<h1>Custom webpart rendering</h1>")
me.mylabel.RenderControl(writer)
writer.Write("<br />")
me.myTextbox.RenderControl(writer)
End Sub
Give it a try...
I've been developing web parts for an ASP.NET site using the standard web user control model, which gives you access to the VS designer and means your UI can be standard HTML. ASP.NET then wraps the UserControl into a GenericWebPart at runtime to host it in a WebParts site.
I know that Sharepoint doesn't support this model out of the box but I've just found this which might help you...
http://weblogs.asp.net/jan/archive/2006/12/02/announcing-the-return-of-the-smartpart.aspx
Smart Part (or a variation of it) is the easiest way to go. Why mess with rendering direct html when you can develop a user control more easily?
Plus if you are not an expert in VB, having Visual Studio Designer will help with creating user controls
i blogged about this very topic. Easily build a rich UI for a web part without using SmartPart
Thanks for all the responses. I've gone with EvilGoatBobs solution as the most immediately easy to implement.
This is my first time on StackOverflow and your helpful answers have made it a really good introduction to the site! :)