Rich Text Box SelectionColor
(Tuesday, January 03, 2006)
Found the following interesting discussion in the Newsgroups:
Rich Text Box SelectionColor by a_poster
| I'm making a real-time spell checker that mimics MS Word's real-time spell checking behavior. As the user types into a rich text box, I detect when a word has been misspelled and modify the visual appearance of the word in some way (currently I just turn it red).
So, using a rich text box, I have to :
a) bookmark my current .selectionStart into some integer b) set .selectionStart to the beginning of the misspelled word c) set .selectionLength to the end of the misspelled word d) set .selectionColor = [red] e) set .selectionStart = bookmarked position
I admit this works - the code's fairly efficient and the PC is fast, so I can accomplish all this faster than anyone can realistically type and the user has no idea their selection is running wild all over the textbox every time they leave a word behind. But I had initially envisioned (not knowing anything about the rich textbox control) a more elegant system of simply pointing to a substring in the text and changing it's color, or font or style or whatever, instantly, and without moving the cursor. Was that a naive dream or is this possible to do without so much modification to the selection?
| | | Reply: by:Sriram Krishnan
| | | Your method is the right one (to the best of my knowledge). But you are right - a more elegant method is necessary. What you say is close to the way Word does it. It puts properties in property bags and every chunk of text refers a property bag. So to change the formatting of some text, you just assign it to some other property bag.
Read Chris Pratley's and Rick Schaut's blog for more details http://blogs.msdn.com/Chris_Pratley http://blogs.msdn.com/Rick_Schaut
-- Sriram Krishnan
|
Posted by Xander Zelders

ListBox non-Dataset load Value and discription
Found the following interesting discussion in the Newsgroups:
ListBox non-Dataset load Value and discription by:Anonymous
| Is there a way to load into a listbox.. one click at a time... one row at a time... both a value & display text without using a bound Dataset? ValueID = 123 DisText = "Bob" Private Sub btnSplitAdd_Click(ByVal sender As System.Object, ByVal e As _ System.EventArgs) Handles btnSplitAdd.Click
lbSplitBrkFee.BeginUpdate() lbSplitBrkFee.Items.Add(ValueID, DisText) lbSplitBrkFee.EndUpdate()
End Sub
User will only see "Bob", but when they click on the listbox I can get access to the ValueID 123
Thanks Brian
| | | Reply: by:Greg Burns
| | | cboT1_PayRate.BeginUpdate() cboT1_PayRate.Items.Clear()
cboT1_PayRate.Items.Add(New ListBoxItem("AN", "Annually")) cboT1_PayRate.Items.Add(New ListBoxItem("HR", "Hourly")) cboT1_PayRate.Items.Add(New ListBoxItem("WK", "Weekly")) cboT1_PayRate.EndUpdate()
.... Public Class ListBoxItem
Private listItemData As Object ' make this whatever datatype most appropriate for you Private listItemText As String
' This is what is displayed in the ComboBox drop-down Public Overrides Function ToString() As String Return listItemText End Function
Public Sub New(ByVal itemData As Object, ByVal itemText As String)
listItemData = itemData listItemText = itemText End Sub
Public ReadOnly Property Data() As Object Get Data = listItemData End Get
End Property
Public ReadOnly Property Text() As String Get Text = listItemText End Get
End Property
End Class HTH, Greg
| | | Reply: by:Greg Burns
| | | forgot to mention; to get value back out, just cast SelectedItem back to custom ListBoxItem class
Dim PayRateCode as String PayRateCode=CType(cboT1_PayRate.SelectedItem, ListBoxItem).Data.ToString
news:O$mT6yKVEHA.3024@TK2MSFTNGP09.phx.gbl... _
| | | Reply: by:Anonymous
| | | Thank you... Workes Great!..
Still don't understand why this is not just part of the LB control.
Oh well it is MS VB.Net ;-D
|
Posted by Xander Zelders

Knew how to do it the old way, but ...
Found the following interesting discussion in the Newsgroups:
Knew how to do it the old way, but ... by:Ed Staffin
| In vb6, I could load a listbox/combobox with strings and values using the list and itemdata properties. WHen I wanted to set the selected item to a value I looked through the itemdata to find a match.
In vb7, I can't quite seem to figure it out. I can set the datasource to a datatable, set the display member, set the value member and have everything display properly. However, once I have loaded the listbox/combobox with the data, I can't figure out how to set the selectedIndex property based on a value I have. I tried looking at the items collection, but near as I can tell, that thing is useless. Any guidance would be greatly appreciated.
Thanks ... Ed
| | | Reply: by:hirf-spam-me-here@gmx.at (Herfried K. Wagner [MVP])
| | |
The direct replacement is using custom objects to store additional data:
<URL:http://www.google.de/groups?selm=2hemflFbikgkU2%40uni-berlin.de> -- Herfried K. Wagner [MVP]
| | | Reply: by:Armin Zingler
| | | http://groups.google.com/groups?threadm=eniMT6RhDHA.3324@TK2MSFTNGP11.phx.gbl> -- Armin
How to quote and why: http://www.plig.net/nnq/nquote.html http://www.netmeister.org/news/learn2quote.html
|
Posted by Xander Zelders

InvalidActiveXStateException error when editing simple form elemen
Found the following interesting discussion in the Newsgroups:
InvalidActiveXStateException error when editing simple form elemen by:Anonymous
| I am trying to edit form elements (labels, text box's, etc) in Visual Studio.NET using VB.NET. Whenever I edit certain forms’ appearance whether it is through the code, or through the designer, I receive this (Invalid ActiveX State Exception) error message at runtime whenever the form is called. I am simply trying to change the size and location of some form elements whose location and size were thrown off during the upgrade from VB6.0 to VB.NET. These are not major changes, just a few pixels at most. In addition, after I get this error, the form that I tried to edit is hosed. It throws this runtime error even if I reverse the changes that I made to the form. It is as if something is changing that is not visible. I make sure that everything in the code is changed back to its original state, but still receive this error message. Any suggestions are greatly appreciated.
| | | Reply: by:hirf-spam-me-here@gmx.at (Herfried K. Wagner [MVP])
| | |
Just FYI:
Your post is visible in my newsreader, so it has been posted successfully. No need to post it several times.
According to your problem: What ActiveX controls do you use on the form? Notice that it's better to use the according Windows Forms controls instead of the old ActiveX controls if possible.
-- Herfried K. Wagner [MVP]
| | | Reply: by:Anonymous
| | | Yeah, I know - sorry about the excessive posting - I kept receiving an error whenever it attempted to post, so I assumed that it was failing. I have several ActiveX controls that I am currently using. They include Toolbars, Dropdown menus, list views, etc. I have even tried to replace the ActiveX controls with their windows forms equivalent, but when I attempt to replace, I receive the same error. So, I am pretty much stuck using the ActiveX controls until I find a solution.
| | | Reply: by:Anonymous
| | | Yeah, I know - sorry about the excessive posting - I kept receiving an error whenever it attempted to post, so I assumed that it was failing. I have several active x controls that I am currently using. They include Toolbars, Dropdown menus, list views, etc. I have even tried to replace the ActiveX controls with their windows forms equivalent, but when I attempt to replace, I receive the same error. So, I am pretty much stuck using the Active X controls until I find a solution.
|
Posted by Xander Zelders

when to use DoEvents in vb.net?
Found the following interesting discussion in the Newsgroups:
when to use DoEvents in vb.net? by:Rich
| As I migrate my VB6 apps to vb.net I am checking what features I need to retain from vb6. In vb6 I noticed that DoEvents really made a performance difference when I called it just before a Do/For loop for large datasets. I hope do some multithreading in vb.net for this. But I am not completely sure about how
System.Windows.Forms.Application.DoEvents()
works, or its application/purpose. Is this the same as the DoEvents from vb6? Should I keep this feature in my vb.net projects?
TIA, Rich
| | | Reply: by:Alex Papadimoulis
| | | I can't say it any better than the documentation ;-)
events. For example, if you have a form that adds data to a ListBox and add DoEvents to your code, your form repaints when another window is dragged over it. If you remove DoEvents from your code, your form will not repaint until the click event handler of the button is finished executing.
So the answer is, it depends. Do you want messages to be processed (such as redrawing)? Or do you want to go for maximum performance and not do it? -- Alex Papadimoulis
| | | Reply: by:hirf-spam-me-here@gmx.at (Herfried K. Wagner [MVP])
| | | There is no 'DoEvents' necessary if you put the dataset processing stuff into a separate thread. -- Herfried K. Wagner [MVP]
| | | Reply: by:Rich
| | | Thanks all for your replies. It sounds like
System.Windows.Forms.Application.DoEvents()
is the same as DoEvents from vb6. Just wanted to make sure.
|
Posted by Xander Zelders

Playing Audio from a Filestream using MCI
Found the following interesting discussion in the Newsgroups:
Playing Audio from a Filestream using MCI by:Gidi Morris via .NET 247
| Hi,
Is there a way to play audio using MCI (I preffer MCI, but if you know of any others I'll be greatful) from a Filestream?
I mean, I have a filestream to an audio file, can I play the audio? I can't access the file directly, so just using the MCI's MCI_OPEN command won't work.
-------------------------------- From: Gidi Morris
| | | Reply: by:hirf-spam-me-here@gmx.at (Herfried K. Wagner [MVP])
| | |
This code should work after doing some changes (reading the byte array from the filestream instead of loading it from a resource):
<URL:http://www.google.de/groups?selm=c71i55%24gvvlh%241%40ID-208219.news.uni-berlin.de>
-- Herfried K. Wagner [MVP]
| | | Reply: by:waw@trfsys.com (Wayde Wyatt)
| | | hirf-spam-me-here@gmx.at (Herfried K. Wagner [MVP]) wrote in message news:<2je97iF10ncdeU6@uni-berlin.de>...
This might be just what you're looking for. A DotNet class wrapper for MCI.
http://www.mentalis.org/soft/class.qpx?id=1
--Wayde
|
Posted by Xander Zelders

XML in a combobox
Found the following interesting discussion in the Newsgroups:
XML in a combobox by:alex5772@hotmail-dot-com.no-spam.invalid (tureypr)
| Hello Wolrd!
I'm trying to add items. to a comboox from a XML file,
I want to add the parents elements to thre combobox and when you select an item in the combobox, in a another combobox display the child elements of the parent element selected.
pleae someone help me
| | | Reply: by:One Handed Man \( OHM - Terry Burns \)
| | | Hi you can create a new DataSet object and real in your data from an XML file, then you can bind the DataSource and DataMember and DataValue properties of the combobox to your DataSet.
HTH - OHM --
OHM ( Terry Burns )
| | | Reply: by:hirf-spam-me-here@gmx.at (Herfried K. Wagner [MVP])
| | |
The solution depends on how data is stored in the XML file. Can you post a sample?
In some cases, the solution posted in the other reply will be the way to go, in more complicated cases you will have to use classes from the 'System.Xml' namespace ('XmlDocument' etc.).
-- Herfried K. Wagner [MVP]
|
Posted by Xander Zelders

Setup Project
Found the following interesting discussion in the Newsgroups:
Setup Project by:Anonymous
| I have added a setup project to a solution. The problem is that once it's added, there are no detected dependencies or any other files inside the project. I can build the project to create the .msi, but when I install it, no files are installed. The other project in the solution, which is my windows application works fine in the ide.
Any ideas what might be going on?
Thanks, Mark
| | | Reply: by:tderksen@online.microsoft.com (Todd Derksen [MSFT])
| | | Mark you are just missing one step. You need to add the project output(s) of your other projects(s) to your setup project. Right click on the setup project and select Add-> Project Output, select the primary output (for the files built by the project). You can also add the other outputs if they are needed for your deployment. I hope that clears things up.
Todd Derksen -------------------- Visual Basic Deployment Test Team This posting is provided "AS IS" with no warranties, and confers no rights. -------------------- it's added, there are no detected dependencies or any other files inside the project. I can build the project to create the .msi, but when I install it, no files are installed. The other project in the solution, which is my windows application works fine in the ide.
|
Posted by Xander Zelders

WMI Com Interop exception handling
Found the following interesting discussion in the Newsgroups:
WMI Com Interop exception handling by:Anonymous
| Hi all,
Using WMI I am attempting to catch and exception when doing a managementscope.connect operation. From the looks of things, this method starts a new worker thread through Interop that then executes the method. My problem is that regardless of what all I use in my catch statements, the system still raises the initial dialog reporting the exception. Eventually, my app catches and handles the exception but I cannot get the initial one. Is there a code snippet somewhere that shows how to hook into the exception event handler in WMI or Interop? I am purposely running this against a machine that does not have WMI enabled to ensure that an error will occur. I'm at a loss on how to handle this. Heres a snip.... and hmmm.. sorry about the formatting.... Public Function blaa() as Boolean Dim options As New ConnectionOptions() Dim scope As ManagementScope Dim blah As String options.Username = "xxxx\Administrator" options.Password = "****" scope = New ManagementScope("\\" & "10.0.1.10" & "\root\cimv2", options) Try scope.Connect() return true Catch e As System.Management.ManagementException Return False Catch e As System.Runtime.InteropServices.COMException Return False Catch e As System.Exception Return False Catch e As Exception Return False End Try End Function
| | | Reply: by:Anonymous
| | | Anyone have any idea's? I searched over in the Interop forum but havn't seen much. Is this something that I'll need to use reflection for possibly? I'm fairly new to this .Net so I'm not real clear on reflection usage. Btw, I've added handlers for current domain unhandled exceptions and for app threadexceptions and I still can't catch the error. Thanks to anyone with any ideas ! :)
| | | Reply: by:Anonymous
| | | Anyone have any ideas on this? I've looked over in the interop forum but havn't seen anything jump out at me. I wonder if this is something that I need to use reflection for perhaps? I'm new to this .Net stuff so I'm not realy clear on how that works. BTW, I've added handlers for the current domain and the app thread exceptions and I still can't catch the initial error.
Thanks to anyone with any ideas ! :)
|
Posted by Xander Zelders

Problem With Mailto Start Process
Found the following interesting discussion in the Newsgroups:
Problem With Mailto Start Process by:Wayne Wengert
| I am using a Sub (see below) to call the default mail application and pass a list of email addresses and a subject. Most of the time this works perfectly but occasionally I get an error ("System NullReferenceException: Object reference not set to an instance of an object"). From what I've been able to determine, this occurs when there is a username (left of the @) with a period such as joe.smith@somesite.com). Has anyone seen this type of problem and have suggestions on how to resolve it?
================ Code ===================== Public Sub StartDefaultMail( _
ByVal [To] As String, _
Optional ByVal Subject As String = "" _
)
Try
Dim psi As New ProcessStartInfo
psi.UseShellExecute = True
psi.FileName = _
Process.Start(psi)
Catch ex As Exception
MsgBox("Exception: " & ex.ToString, MsgBoxStyle.Information, "Error")
Throw _
New Exception( _
ex _
)
End Try
End Sub
| | | Reply: by:hirf-spam-me-here@gmx.at (Herfried K. Wagner [MVP])
| | |
Is it possible to get the callstack for the exception?
-- Herfried K. Wagner [MVP]
| | | Reply: by:Wayne Wengert
| | | Herfried;
Is this what you need?
at Microsoft.Win32.NativeMethods.ShellExecuteEx(ShellExeuteInfo info) at System.Diagnostics.Process.StartWithShellExecuteEx(ProcessStartInfo startinfo) at System.Diagnostic.Process.Start() at System.Diagnostics.Process.Start(ProcessStartInfo startInfo) at OfficeApp.Module1.StartDefaultNail(String To, String Subject) in c:\2005 myProjects\TestApp2\Module1.vb:line 100
Wayne
| | | Reply: by:hirf-spam-me-here@gmx.at (Herfried K. Wagner [MVP])
| | |
Yes, but I still don't have an idea.
2005 -- are you using VS 2005 (CTP?)? -- Herfried K. Wagner [MVP]
| | | Reply: by:Wayne Wengert
| | | Nope - VS Net 2003
Wayne
|
Posted by Xander Zelders

|
|
|
|