|
In the user controls class add
Public event TextChanged(sender as object, e as event args)
Under the textboxs normal event handler
eg
<br />
private sub TextBox1_TextChanged(sender as object, e as event args) handles textbox1.TextChanged<br />
raiseevnt textchanged(sender,e) 'Add this line<br />
end sub<br />
Now when the text boxs text is changed the event TextChanged will be raised.
It would also be possible to change this to:
Public event TextChanged(TheTextBox as textbox, TheText as string)
and
<br />
private sub TextBox1_TextChanged(sender as object, e as event args) handles textbox1.TextChanged<br />
raiseevnt textchanged(TextBox1,Textbox1.text) 'Add this line<br />
end sub<br />
So now you can also see what the text is and access the text box.
This may be a little over complicated but I dont call myself an expert but I hope this helps.;)
I'm not dumb I just have a huge command of thouroughly usless infromation.
|
|
|
|
|
Thank you for the insight, you've got me looking down the right path now, but I am still haveing difficulty getting it to work. Here are some more details on my situation...I actually have a user control derived from a user control.
The most primitive contro is called "FileFolderTextBox" and it's just a class that Inherits from System.Windows.Forms.TextBox. The contents of the text box is just a string that should be the path to a file or a folder, and if the text does not match an existing file or folder, the background color gets changed. Pretty simple, and that worked and is based on the TextChanged event.
The next control is a FolderBoxAndButton and a FileBoxAndButton class. Both of these classes Imports the FileFolderTextBox and simply adds a button that allows a user to select the file or folder.
Finally, I have a project that uses the FolderBoxAndButton class, and now I want to do something on the event that the text changes in the FolderBoxAndButton object.
So, in the FileFolderBoxAndButton class, I already have Private Sub FileFolderTextBox_TextChanged(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.TextChanged which changes the background color of the textbox. When I add Public Shadows Event TextChanged(ByVal sender As Object, ByVal e As System.EventArgs) to the class and raise the event in my FileFolderTextBox_TextChanged sub, the event no longer fires (the background color never changes).
Am I just confused onwhat goes where or what am I missing?
And thank you for the help.
|
|
|
|
|
Hello, I have a CheckedListBox control on my form.The user can add items to the list and check or uncheck any item they wish. They can edit and remove items. This far, I am ok with the coding, however, when the form closes, I want all those items that are checked to be removed, but I am not sure how to go about this at all. I have tried a Loop unsuccessfully and attempted a for/next, however, i have made no progress. I also need to save all the non-checked items to a setting.
I am using visual studio 2005 (language vb.net). Any help would be greatly appreciated.
Posted by The ANZAC
|
|
|
|
|
As far as too remove the checked items this should do it
<br />
Dim CIs As Windows.Forms.CheckedListBox.CheckedIndexCollection = CheckedListBox1.CheckedIndices<br />
Dim UnCheckedItems As New List(Of Object)<br />
<br />
For CI As Integer = CIs.Count - 1 To 0 Step -1<br />
CheckedListBox1.Items.RemoveAt(CI)<br />
Next<br />
<br />
'As for saving the rest<br />
For x As Integer = 0 To CheckedListBox1.Items.Count - 1<br />
UnCheckedItems.Add(CheckedListBox1.Items.Item(x))<br />
Next<br />
You have to remove them in reverse order otherwise you will get an index out of range exception before the end of the loop or remove incorrect items (I found this out my own experience)
As for saving to a setting, in the example i've used a generic list to save the remaining items, which could be set up in a module or something
I'm not dumb I just have a huge command of thouroughly usless infromation.
|
|
|
|
|
Thanks, I really appreciate it.
Posted by The ANZAC
|
|
|
|
|
Glad I could help
I'm not dumb I just have a huge command of thouroughly usless infromation.
|
|
|
|
|
I have a transparent form (border style 0) that has no maximize button. Still when I double-click the window, it maximizes. Is there a way to prevent this happen when doubleclicking? And if there is a built-in keyboard combination in Windows XP to maximize windows, I would like to prevent that too.
Thanks!
|
|
|
|
|
Use the MinimumSize and MaximumSize properties (set them to the same value).
|
|
|
|
|
Thanks, but I have tried that. Window still gets maximized.
I have used this code to make my form movable:
Protected Overrides Sub WndProc(ByRef m As _
System.Windows.Forms.Message)
Const WmNcHitTest As Integer = &H84
Const HtCaption As Integer = 2
If m.Msg = WmNcHitTest Then
m.Result = New IntPtr(HtCaption)
Else
MyBase.WndProc(m)
End If
End Sub
Maybe there is the problem?
|
|
|
|
|
Doesn't anyone know how to solve my problem?
|
|
|
|
|
We're sorry, you caught us all on a Holiday Weekend, in the States anyway. It's very rude to demand an answer in a forum environment.
Dave Kreskowiak
Microsoft MVP - Visual Basic
|
|
|
|
|
I'm wondering what you put in to make it do that. I put a little test project together, turned the FormBorderStyle to None (0) and can't duplicate the behavior you're talking about.
Dave Kreskowiak
Microsoft MVP - Visual Basic
|
|
|
|
|
What's that piece of code supposed to do?
|
|
|
|
|
The border style is set to zero and the form is transparent. The code snippet I posted makes the form movable. When I double click the form it will maximized. This is strange.
|
|
|
|
|
I am working on Linux right now, so I cannot check this, but maybe you could try to set an appropriate size of your form in OnResized or OnMaximized (I guess that there are such events) event handlers.
|
|
|
|
|
Why not use plain old .NET code to make the form movable? You won't have this problem then.
|
|
|
|
|
Hello, I am new to writing console applications in VB.NET. I need some advice on how to get the little bit of text after the .exe /.
For example if I open a command window and type
program.exe /help or something like that
Or if you type
program.exe /? It will show help....
Thanks in advanced.
Aaron
|
|
|
|
|
Hi,
use command line arguments!
command line arguments means the arguments you pass to your applications main() method.
hope this works.
Nitin...
|
|
|
|
|
Hmmmm, OK I know exactly what yo mean...
But how?
Thanks again
Aaron
|
|
|
|
|
Your Sub Main can be changed to this:
Function Main(ByVal CmdArgs() As String) As Integer
Dim ArgNum As Integer ' Index of individual command-line argument.
If CmdArgs.Length > 0 Then ' See if there are any arguments.
For ArgNum = 0 To UBound(CmdArgs)
' Examine CmdArgs(ArgNum) for settings you need to handle.
Next ArgNum
End If
Return 0 ' Zero usually means successful completion.
End Function
You can find more information here[^].
Dave Kreskowiak
Microsoft MVP - Visual Basic
|
|
|
|
|
Thanks, I think I will get i working from here...
Thanks again
Aaron
|
|
|
|
|
Hi!
I'm using XMLTextReader and GetAttribute in order to parse a XML file. The problem is that the the file isn't 100% valid XML. File begins with many lines of "#####". My application works fine if I remove these lines from the file. But if I don't want to modify it, I keep getting error "Exception System.Xml.XmlException was thrown in debuggee: Data at the root level is invalid. Line 1, position 1."
Is there a way to write a code that doesn't mind these non-valid expression and manages to parse the attribute correctly?
With best regards,
RI
|
|
|
|
|
Hi,
Does anyone know how to do a search for files like in windows using vb.net.
thanks
|
|
|
|
|
Hello, I noticed your comment, and realised i had a similar need not so long ago, so i took it upon myself to create a program, which searches a chosen directory for a chosen file.
This program is basic and still glitchy, but should provide you with information you need on file searching. What is your email, so that i can email it to you.
Posted by The ANZAC
|
|
|
|
|
I'm trying to save the image to sql database, there is error "object must implement Iconvertible" when I run it. Here is my code:
(image is the location + the name of the image)
Try
Dim strFn As String = image
Dim fiImage As FileInfo = New FileInfo(strFn)
Me.m_lImageFileLength = fiImage.Length
Dim fs As FileStream = New FileStream(strFn, FileMode.Open, FileAccess.Read, FileShare.Read)
m_barrImg = New Byte(Convert.ToInt32(Me.m_lImageFileLength)) {}
Dim iBytesRead As Integer = fs.Read(m_barrImg, 0, Convert.ToInt32(Me.m_lImageFileLength))
fs.Close()
Catch ex As Exception
MessageBox.Show(ex.Message)
End Try
Try
Me.SqlConnection1.Open()
If SqlCommand1.Parameters.Count = 0 Then
Me.SqlCommand1.CommandText = "UPDATE HRRecordIndexData SET pdf_location = @Picture WHERE entity_id = @ID"
Me.SqlCommand1.Parameters.Add("@Picture", System.Data.SqlDbType.Image)
Me.SqlCommand1.Parameters.Add("@ID", System.Data.SqlDbType.Int, 4)
End If
Me.SqlCommand1.Parameters("@Picture").Value = Me.m_barrImg
Me.SqlCommand1.Parameters("@ID").Value = Entity
Me.SqlCommand1.ExecuteNonQuery()
Catch ex As Exception
MessageBox.Show(ex.Message)
Finally
Me.SqlConnection1.Close()
End Try
If there is everyone knows what it needs to fix at my code, I would very appreciate it .. thanks!
Lisa
|
|
|
|