.NET Tutorials, Forums, Interview Questions And Answers
Welcome :Guest
Sign In
Win Surprise Gifts!!!

Top 5 Contributors of the Month
Gaurav Pal
Post New Web Links

use icons for richtextbox

Posted By:      Posted Date: September 14, 2010    Points: 0   Category :Windows Application
(using vb.net 2008).  I am using the richtextbox (WinForms, not WPF) to stream messages to the user.  I'd like to insert symbols with the messages, particularly the red exclamation point of ErrorProvider for warning messages (I'm not saying I need errorProvider itself, just like to use its symbol).  The symbols should position and size themselves appropriately depending upon the richtextbox font or style. I guess question 1 is, am I really on the right track using the WinForm richtextbox for this purpose, or is this functionality too difficult?  If not, how would I insert the errorprovider's exclamation point icon into the RTF?  

View Complete Post

More Related Resource Links

Windows with C++: Decoding Windows Vista Icons with WIC


In this month's installment, Kenny Kerr sings the praises of the new Visual C++ 2008 Feature Pack, which brings modern conveniences to Visual C++.

Kenny Kerr

MSDN Magazine June 2008

Shrunken Icons after using Accessibility Wizard

I have somewhat bad eyesight so went, via All Programmes > Accessories > Accessibility, to the Accessibility Wizard and  tried out the different font sizes available there.  I then attempted to return them to their default settings.  All fonts were returned to their former sizes, EXCEPT the top line text & icons (i.e. "xxxxx - Windows Internet Explorer" and the Shrink, Enlarge and Cancel icons) which were only about half their customary size and, therefore, much less easy to use.
The Accessibility Wizard is set on "Use usual text size for Windows" and any attempt to alter it to one of the two alternative settings, "Use large window titles and menus" or "Use Microsoft Magnifier, and large titles and menus" increases the size of ALL text and menus to rather larger than I need.  How can I restore just the top line to its former larger size and visibility without affecting the normal settings of everything else? 
It turned out that I needed glasses for computer use, so would appreciate help in getting my Windows page back to its reliable default setting.  Many thanks.

Printing RichtextBox

I was using the following code to print the contents of a richtextbox:         pd.PrintDocument(((CType(Me.richTextBox.Document, IDocumentPaginatorSource)).DocumentPaginator), "printing as paginator")but it prints in 3 columns. So i tried using this code but it does not print InluneUiContainersDim docWriter As XpsDocumentWriter = PrintQueue.CreateXpsDocumentWriter(ia)     If (docWriter IsNot Nothing And ia IsNot Nothing) Then         Dim paginator As DocumentPaginator = CType(fd, IDocumentPaginatorSource).DocumentPaginator         'Change the PageSize and PagePadding for the document to match the CanvasSize for the printer device.         paginator.PageSize = New Size(ia.MediaSizeWidth, ia.MediaSizeHeight)         Dim pagePadding As Thickness = fd.PagePadding         fd.PagePadding = New Thickness    (Math.Max    (ia.OriginWidth,     pagePadding.Left),     Math.Max    (ia.OriginHeight,     pagePadding.Top),         Math.Max(ia.MediaSizeWidth - (ia.OriginWidth + ia.ExtentWidth), pagePadding.Right), Math.Max(ia.MediaSizeHeight - (ia.OriginHeight + ia.ExtentHeight), pagePadding.Bottom))     fd.ColumnWidth = Double.PositiveInfinity     'Send DocumentPaginator to the printer.     docWriter.Write(paginator) End If Also tried the following but this is completely wrong:        pd.PrintVisual(CType(Me.richTextBox, Visual), "printing as visual")Any ideas?

Vista Icons

I have written a windows forms .net application which creates, edits, and converts bitmaps to icons. However, the finished icons look pixelated and sometimes change colors to grayscale (even though the icons properties say it's 32-bit, just like the other icons on my system). I think the problem is that I have Vista, and the code is creating xp icons or something. I hear that vista and 7 icons are significantly different, so I was wondering how to create these vista icons in Visual Studio. Here's my code (it runs when the user clicks a button): Image^ pictureBoxImage = pictureBox1->Image; Bitmap^ bmp = gcnew Bitmap(pictureBoxImage); System::Drawing::Icon^ icon = Icon->FromHandle(bitmap->GetHicon()); FileStream^ imageFile = File::Create(textBox2->Text); icon->Save(imageFile); By the way, although I use C++ I can understand C# and VB code, so feel free to give me code samples in those languages.

RichTextBox - Attached Properties, Document and CaretPosition

Hi I have created a couple of attached properties for the richtextbox control, to enable binding to the Document and CaretPosition native properties of the richtextbox. However, I am finding that, when I am programmatically updating the richtextbox document from the view model (rather than typing it into the richtextbox directly), I need to manually set the CaretPosition property of the richtextbox (see the underlined piece of code for the additional manual setting of CaretPosition) whereas the Document property appears to be updating automatically. At least when I step the code and break in on I'm concerned that I've not quite wired this together properly and would be grateful if someone could explain where I've got it wrong. The relevant  XAML is  <RichTextBox x:Name="rtb" Height="auto" Width="auto" local:RichTextBoxExtensions.CaretPosition="{Binding CaretPosition, Mode=TwoWay}" local:RichTextBoxExtensions.CurrentText="{Binding CurrentText, Mode=TwoWay}" cal:Message.Attach="[Event TextChanged] = [Action CheckForPopup]; [Event PreviewKeyUp] = [Action KeyPress($eventArgs)]"> <local:RichTextBoxExtensions.Document> <MultiBinding Converter="{StaticResource IntellisenseController}"> <Binding Path="CurrentDocument" Mode=&qu

Full desired height of a RichTextBox control?

I don't mean the control's .Height property... ...I have a WinForm with a RichTextBox control, and another control underneath the RichTextBox control.  The RichTextBox control is anchored on the left, top, and right sides, so the width is automatically resized as the parent form is resized.  (it also has its Multiline and and WordWrap properties set to True) The item underneath the RichTextBox needs to always be right underneath it (little whitespace), and the RichTextBox needs to always display its entire text (nothing hidden). As I get the form's resize event, I'd like to update the RichTextBox's hight so all text is displayed, however I'm not seeing any properities or methods which would be helpful.  There is the PrefferredHeight property, but it is always returning 13. Basically, it comes dowen to this: when WordWrap is set to true, is there a way to see what the desired height is?  Or is there a way to see if any of the text is clipped? If not, I suppose my next step would be to roll my own custom control and draw the text myself, keeping track of the autowrap and line count, but I thought I'd post a message here first and see if anyone has a better idea. Thanks, Jeff      

double spin text in richtextbox

i want to implement this feature : if i have a following sentence : {my name is james vick and iam a {member|user|visitor} on this {forum|website|site} and iam loving it | iam admin and iam a {supervisor|admin|moderator} on this {forum|website|site} and iam loving it} on a click of button i want to generate this : my name is james vick and iam a member on this site and iam loving it or iam admin and iam a admin on this forum and iam loving it The basic need is to randomly choose words between {|} braces I have been able to do this for inner nest i.e. for {member|user|visitor}. But how to include the outer nest of sentences also i.e. {something blah blah {blah1|blah2} and | something else} ? code for inner nest : Private Sub SimpleButton3_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles SimpleButton3.Click Dim stringWithTextIn As String = RichTextBox1.Text Dim regex As New Regex("{(.*?)}") Dim r As String = regex.Replace(stringWithTextIn, New MatchEvaluator(AddressOf ReplaceMatch)) RichTextBox2.Text = r End Sub Private Function ReplaceMatch(ByVal m As Match) As String Dim parts = m.Groups(1).Value.Split("|"c) Return parts(r.Next(0, parts.Length)) End Function i know i just have to change the regex but what do i add in it to include outer braces?

missing event in RichTextBox

I'm developing an application that uses the RichTextBox extensively, I need an event that gets triggered at the moment when the vertical scroll bar of the richTectBox appears . so instead of scrolling down to see the rest of the text I want to create another RichTextBox that will hold the rest of the text which didn't fit in the first one …I want to achieve the same functionality as in MS word. I tried so hard to achieve that functionality but it wasn't successfull … I tried to fake it using the SizeChanged event but it wasn't practical because the size of the richTextBox gets changed a lot during the life time of the application   is there such event in windows forms ? … and if not , is there one in WPF ?

App_Code file icons

 Can anyone tell me why some of the xxx.vb class file icons have a 'vb' in the upper left corner of the icon and some have 'three little squares' in a reverse 'L' shape in the upper left corner of the icon ?

Problem when Append DataFormats.xamlPackage RichTextBox

public partial class Window12 : Window { public Window12() { InitializeComponent(); } FileStream fStream; private void btnClick_Click(object sender, RoutedEventArgs e) { TextRange ran = new TextRange(txtMsg.Document.ContentStart, txtMsg.Document.ContentEnd); ran.Save(fStream, DataFormats.XamlPackage); txtMsg.Document.Blocks.Clear(); txtMsg.Focus(); } private void Window_Loaded(object sender, RoutedEventArgs e) { string fileName = @"D:\\part1.xaml"; if (File.Exists(fileName)) fStream = new FileStream(fileName, FileMode.Append, FileAccess.Write); else fStream = new FileStream(fileName, FileMode.Create); txtMsg.Focus(); } private void Window_Closing(object sender, System.ComponentModel.CancelEventArgs e) { fStream.Close(); } } Hi, I have WPF RichTextbox and a button When I insert the text or Image and Click the button the text will save in D: drive with DataFormats.XamlPackage Initially it works fine, when I try to append the text (Close window and open again then insert the text )It gives the error in range.Save(fStream,DataFormats.XamlPackage); Error Message:Cannot open package because FileMode or FileAccess value is not valid for the stream.am

Possibly Severe Bug in Windows Forms / TextBox / RichTextBox, Windows Freezing

Problem: Windows Message Processing (in all running apps) completely freezing periodically for about 10 seconds when using certain combination of Forms properties on a form with a TextBox/RichTextBox. This behaviour might not be limited to the two controls. The weird behaviour starts with but is not limited to scrolling text in the textbox with the mousewheel. Using: Visual Studio 2008, Visual Basic, compiling for .NET Framework 3.5 (Any) OS: Windows XP SP3 Reproduce: Open new project, add a new form named TestForm, add a TextBox named TextBox1, enable scrollbars on the TextBox. Add the following function to the form: Public Class TestForm     Private Sub TestForm_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load         ' CONDITIONS WHEN STARTS TO SLOW DOWN:         ' Form.Opacity < 1.0         ' Form.BackColor = Form.TransparencyKey (= whole form is transparent)         ' this makes the form completely transparent         BackColor = Color.Red         TransparencyKey = Color.Red         ' NOTE: when this is set it starts to slow down         Opac

Crystal report viewer icons are misssing in VS2010

Hi, After installing VS2010, i have upgraded my VS2008 application to VS2010. When i run the asp.net page, it shows report correctly but crystal report viewer tool bar icon's are missing? Following folder is empty: C:\Inetpub\wwwroot\aspnet_client\system_web\4_0_30319 I have tried to copy contents from C:\Inetpub\wwwroot\aspnet_client\system_web\2_0_50727\CrystalReportWebFormViewer4 to 4_0_30319 folder but icons are still missing. Do i need to install crystal report for VS 2010?

What is the recommended format for vector icons in resource dictionary?

It seems that Expression Design wants to export vector graphics in resource dictionary format as DrawingBrushes.  These are a bit of a pain to use in something like a MenuItem.Icon.  So I have been converting the DrawingBrushes to DrawingImages.  The only downside I've run into so far is that I can't figure out how to force the DrawingImage to be a certain size say 20x20 where the content may not take up that whole size.  The issue is that when you put these vector icons on a toolbar and you want the images to align, it is tricky when each icon is a slightly different height.

How can I hide the caret of a RichTextBox control?

Hello,Can you please tell me how can I hide the caret of a RichTextBox control completely while my app is running?Thanks.

Richtextbox - how can I find out what lines are currently visible?

I have a scrolling richtextbox that holds more lines than it can display, and I would like to know what lines are currently being displayed.  I'm looking for some method like GetTopVisibleLine, GetBottomVisibleLine, GetFirstVisibleCharIndex, GetLastVisibleCharIndex, etc. and I don't seem to be able to find anything that will give me this info.  Any ideas? Thanks, Mike
ASP.NetWindows Application  .NET Framework  C#  VB.Net  ADO.Net  
Sql Server  SharePoint  Silverlight  Others  All   

Hall of Fame    Twitter   Terms of Service    Privacy Policy    Contact Us    Archives   Tell A Friend