|
NANCO wrote: I don't know; I just got the code, it doesn't work.
Getting code off the web is fine, so long as you're able to understand it. If you can't understand it, then you should stop and work through a book, so you know enough VB.NET that the web helps you with syntax, not with writing code.
To store a color, you'd probably store the red, green and blue components as integers, then you'd use those to create a color again.
Christian Graus - Microsoft MVP - C++
Metal Musings - Rex and my new metal blog
"I am working on a project that will convert a FORTRAN code to corresponding C++ code.I am not aware of FORTRAN syntax" ( spotted in the C++/CLI forum )
|
|
|
|
|
Hi there,
The statement 'textbox1.BackColor = ColorDialog1.Color' generates a boolen value, not the value of the color code. Do it as follow:
TextBox1.BackColor = ColorDialog1.Color
' Save to registry
SaveSetting("program", "programSettings", "bgcolor", TextBox1.BackColor.ToArgb)
' Apply from registry
Me.TextBox1.BackColor = Drawing.Color.FromArgb(GetSetting("program", "programSettings", "bgcolor"))
Regards, Werries
A programmer's life is good... or is it?? Ek dink nie so nie!
|
|
|
|
|
Hi! could anyone tell me how to convert a string(that is a font) that I saved to to reg using savesetting(..) to font object using getsetting(..) so I can assign it back a textbox.
summary: convert string back to font
thanx in advance.
|
|
|
|
|
Well, what is the value of the string ? Does it specify font name, size, weight, etc ?
Christian Graus - Microsoft MVP - C++
Metal Musings - Rex and my new metal blog
"I am working on a project that will convert a FORTRAN code to corresponding C++ code.I am not aware of FORTRAN syntax" ( spotted in the C++/CLI forum )
|
|
|
|
|
Hi there,
The best is to save each setting of the font into its own registry entry, or save the settings of the font in delimited format into one registry entry and reverse it into a new font value that you can apply to the textbox.
Regards, Werries
A programmer's life is good... or is it?? Ek dink nie so nie!
|
|
|
|
|
I found a way, thanks anyway.
|
|
|
|
|
Hi,I'm trying to create a database connection...
connstr as string
connstr="DSN=****;uid=***;pwd=***"
.....
what do you suggest to make it more secure since the connection string is stored in the app.config.
I have tried using the rsaprotectedconfigurationprovider like what the msdn recommended...
Imports System
Imports System.Configuration
Public Class UsingRsaProtectedConfigurationProvider
' Protect the connectionStrings section.
Private Shared Sub ProtectConfiguration()
' Get the application configuration file.
Dim config As System.Configuration.Configuration = _
ConfigurationManager.OpenExeConfiguration(ConfigurationUserLevel.None)
' Define the Rsa provider name.
Dim provider As String = _
"RsaProtectedConfigurationProvider"
' Get the section to protect.
Dim connStrings As ConfigurationSection = _
config.ConnectionStrings
If Not (connStrings Is Nothing) Then
If Not connStrings.SectionInformation.IsProtected Then
If Not connStrings.ElementInformation.IsLocked Then
' Protect the section.
connStrings.SectionInformation.ProtectSection(provider)
connStrings.SectionInformation.ForceSave = True
config.Save(ConfigurationSaveMode.Full)
Console.WriteLine( _
"Section {0} is now protected by {1}", _
connStrings.SectionInformation.Name, _
connStrings.SectionInformation.ProtectionProvider.Name)
Else
Console.WriteLine( _
"Can't protect, section {0} is locked", _
connStrings.SectionInformation.Name)
End If
Else
Console.WriteLine( _
"Section {0} is already protected by {1}", _
connStrings.SectionInformation.Name, _
connStrings.SectionInformation.ProtectionProvider.Name)
End If
Else
Console.WriteLine( _
"Can't get the section {0}", _
connStrings.SectionInformation.Name)
End If
End Sub 'ProtectConfiguration
' Unprotect the connectionStrings section.
Private Shared Sub UnProtectConfiguration()
' Get the application configuration file.
Dim config As System.Configuration.Configuration = _
ConfigurationManager.OpenExeConfiguration(ConfigurationUserLevel.None)
' Get the section to unprotect.
Dim connStrings As ConfigurationSection = _
config.ConnectionStrings
If Not (connStrings Is Nothing) Then
If connStrings.SectionInformation.IsProtected Then
If Not connStrings.ElementInformation.IsLocked Then
' Unprotect the section.
connStrings.SectionInformation.UnprotectSection()
connStrings.SectionInformation.ForceSave = True
config.Save(ConfigurationSaveMode.Full)
Console.WriteLine( _
"Section {0} is now unprotected.", _
connStrings.SectionInformation.Name)
Else
Console.WriteLine( _
"Can't unprotect, section {0} is locked", _
connStrings.SectionInformation.Name)
End If
Else
Console.WriteLine( _
"Section {0} is already unprotected.", _
connStrings.SectionInformation.Name)
End If
Else
Console.WriteLine( _
"Can't get the section {0}", _
connStrings.SectionInformation.Name)
End If
End Sub 'UnProtectConfiguration
Public Shared Sub Main(ByVal args() As String)
Dim selection As String = String.Empty
If args.Length = 0 Then
Console.WriteLine( _
"Select protect or unprotect")
Return
End If
selection = args(0).ToLower()
Select Case selection
Case "protect"
ProtectConfiguration()
Case "unprotect"
UnProtectConfiguration()
Case Else
Console.WriteLine( _
"Unknown selection")
End Select
Console.Read()
End Sub 'Main
End Class 'UsingRsaProtectedConfigurationProvider
but I can't find system.configuration.configuration and configurationmanager.
Also, i tried searching in the object browser the configurationmanager, and it says that its part of system.configuration, but still can't find it...
|
|
|
|
|
1. Add the connection string to the web.config section
<configuration>
<connectionStrings>
<add name="DBConnectionString" connectionString="whatever" />
</connectionStrings>
...
/configuration>
2. Add a <machineKey> element to your web.config:
<configuration>
...
<system.web>
<machineKey validationKey="AutoGenerate,IsolateApps"
decryptionKey="AutoGenerate,IsolateApps" />
</system.web>
</configuration>
3. Run aspnet_regiis.exe tool to encrypt the <connectionStrings> element:
aspnet_regiis -pe "connectionStrings" -app "[Your App Name]"
4. Run the aspnet_regiis.exe tool to encrypt the <machineKey> element:
apnet_regiis -pe "system.web/machineKey" -app "[Your App Name]"
5. Run the aspnet_regiis.exe tool to grant access to the key container by the ASP.NET identity:
apsnet-regiis -pa "NetFrameworkConfigurationKey" "[ASP.NET User]"
Referenced: "ASP.NET 2.0 Cookbook, Second Edition, Michael A. Kittel and Geoffrey T. LeBlond. © 2006 O'Reilly Media, Inc., 0-596-10064-7."
-- modified at 8:18 Sunday 15th April, 2007
"We make a living by what we get, we make a life by what we give." --Winston Churchill
|
|
|
|
|
Do you have a windows app version? Does aspnet_regiis work on windows app? Thanks.
|
|
|
|
|
1)i created form1.vb in that top placed label
2)right hand side placed a panle2
3)and left hand side i placed panel1.
4)in panel1 i placed one button.
5)created usercontrol.vb
my question is if i click on button the from is redirect to usercontrol.vb but it place on panel2
i want o/p as
in from.vb top label,left side panel1, and right side is usercontrol.vb
how i can do this
karim
-- modified at 22:46 Saturday 14th April, 2007
|
|
|
|
|
When you say redirect, is this a web app ?
Christian Graus - Microsoft MVP - C++
Metal Musings - Rex and my new metal blog
"I am working on a project that will convert a FORTRAN code to corresponding C++ code.I am not aware of FORTRAN syntax" ( spotted in the C++/CLI forum )
|
|
|
|
|
Hello World! I am trying to create a dependency between a list box and checklistbox. For example, I want to select 1 state from a list of states and then have all of the cities associated to that state populate in a checklistbox. Right now, all I have is
Public Class Form1
Dim sStates As String()
Dim sCities As String()
Dim iStateCities As Integer()
Dim iNumCities As Integer()
Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
ReDim sStates(2)
sStates(0) = "Texas"
sStates(1) = "Colorado"
sStates(2) = "Nevada"
ReDim sCities(5)
sCities(0) = "Austin"
sCities(1) = "Dallas"
sCities(2) = "Denver"
sCities(3) = "Vail"
sCities(4) = "Las Vegas"
ReDim iStateCities(sStates.Length - 1)
iStateCities(0) = 0 'The sCities array location Texas'cities start at
iStateCities(1) = 2 'The sCities array location Colorado's cities start at
iStateCities(2) = 3 'The sCities array location Nevada's cities start at
ReDim iNumCities(sStates.Length - 1)
iNumCities(0) = 0 'The number of Cities in your sCities array that are in Texas
iNumCities(1) = 3 'The number of Cities in your sCities array that are in Colorado
iNumCities(2) = 4 'The number of Cities in your sCities array that are in Nevada
ListBox1.Items.AddRange(sStates) 'populate the state listbox
End Sub
Private Sub ListBox1_SelectedIndexChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ListBox1.SelectedIndexChanged
CheckedListBox1.Items.Clear() 'clear out the cities in the city checkedlistbox
Dim myLoop As Integer = 0
ReDim iNumCities((ListBox1.SelectedIndex) - 1)
CheckedListBox1.Items.Add(sCities(iStateCities(ListBox1.SelectedIndex) + myLoop))
End Sub
Private Sub CheckedListBox1_SelectedIndexChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles CheckedListBox1.SelectedIndexChanged
End Sub
End Class
|
|
|
|
|
The events look like VB.NET, but you're using Redim, why ? Why not use collections ?
You don't seem to have any code to connect the collections of cities with a state name, you need a dictionary for that. You also don't have any event handler code for the selection change.
Christian Graus - Microsoft MVP - C++
Metal Musings - Rex and my new metal blog
"I am working on a project that will convert a FORTRAN code to corresponding C++ code.I am not aware of FORTRAN syntax" ( spotted in the C++/CLI forum )
|
|
|
|
|
I have a whole DataSet with fields of Zip Code, Lat, Lon, City, State, County and I'm trying to figure out how to query this DataSet by the user specifying the zip code in an options dialog and clicking a check button that calls a function that will search through my table called ZipCodes by the ZipCode and it returning it's whole row so I can display this data in textboxes and for other things the program will use it for.
Any code that will help me do this will be appreciated as it is too complex for me to think it out.
|
|
|
|
|
Have you tried searching for "dataset" on this web site? There are several articles on datasets and ADO.NET out of over 15,000 articles. Also, you can search the forums too!
"We make a living by what we get, we make a life by what we give." --Winston Churchill
|
|
|
|
|
hi
Does anyone know how to change the Microsoft Agent Control voice to women voice?
Is there a way to change it?
Thanks,
Aung Myo Aye
|
|
|
|
|
I think you just change the sound pitch, but I could be wrong.
Trinity: Neo... nobody has ever done this before.
Neo: That's why it's going to work.
|
|
|
|
|
One way is tho use Agent Character Creator. Dealing with Agent voices is explained here (scroll to "Setting Your Character's Output Options").
Also, as MS Agent uses Text-to-Speech feature, this can help.
Hope it helps,
- Dmitry.
-------------------------
Don't worry, be happy )
|
|
|
|
|
I have migrated a VB.Net 2003 forms project to 2005 Express Edition. This went surprisingly well.
One problem remains.
The main form sets up a delegate system to update it's text property from a background thread.
Public Class FormMain
Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
'other stuff
frmTxt = New FormText(AddressOf WriteFormText)
End Sub
#Region "Delegates"
Public frmTxt As FormText
Public Delegate Sub FormText(ByVal inText As String)
Private Sub WriteFormText(ByVal inText As String)
Try
Me.Text = inText
Catch ex As Exception
Shw.Err("frmMain.WriteFormText " & ex.Message)
End Try
End Sub
#End Region
End Class
A class "Clock" runs on a background thread and updates the main form's text once a second to show the time.
Public Class clsClock
Private Sub MainLoop() '8/9/05
Do
'determine if it is a new second using Now.Second and set isNewSecond accordingly
if isNewSecond = True Then
frmMain.frmTxt.BeginInvoke("TheCore" & Space(100) & Now.ToString, Nothing, Nothing)
End If
'do all kinds of things depending on the time
Thread.Sleep(100)
Loop
End Sub
End Class
Running in .Net 1.1, this works fine, in .Net 2.0 it throws this error
"Cross-thread operation not valid: Control 'FormMain' accessed from a thread other than it was created on."
I have a system of delegates to update a progress bar from background threads and a system of delegates to write to a picture box from background threads. Both of these work correctly in 2005.
Help and my books have not solved the problem. Several hours of Google has only found other folks with the same problem.
Does anyone know how to fix it?
Thanks
RCarey
RCarey
|
|
|
|
|
|
Hello,
VS 2005
I have a user control. On the parent form i have placed my user control inside a tab control. Inside the user control i have fields for saving and deleting tasks.
When a user wants to delete a task the taskID is taken from the tab name and passed to the user control in a public property. So I know what task I want to delete.
<br />
'Code in the user control<br />
Public Property TaskID() As Integer<br />
Get<br />
Return _taskID<br />
End Get<br />
Set(ByVal value As Integer)<br />
_taskID = value<br />
End Set<br />
End Property
'
In the parent form I get the TaskID from the tab name and pass it to the public property<br />
Private Sub TabControl1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles TabControl1.Click<br />
Try<br />
Dim taskID As Integer = 0<br />
<br />
taskID = Integer.Parse(Me.TabControl1.SelectedTab.Name)<br />
newTask.TaskID = taskID<br />
Catch ex As Exception<br />
MessageBox.Show(ex.Message)<br />
End Try<br />
End Sub
But the problem is when I delete I want to be sure that the deletion was successful and pass this back to the parent control. And that is something I can't see to do.
For example: if there was a problem with the delete then I don't want to delete the tab but inform the user there was a problem.
'code in the user control for deleting the task, but if not successful, how do i send this back to the parent control?<br />
Private Sub btnDelete_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnDelete.Click<br />
Try<br />
Dim rowsAffected As Integer = 0<br />
rowsAffected = Me.TA_IncidentTask1.DeleteTask(_taskID)<br />
If (rowsAffected = 0) Then<br />
'Not successful so how do i inform the user<br />
End If<br />
Catch ex As Exception<br />
MessageBox.Show(ex.Message)<br />
End Try<br />
End Sub
I am ok at passing information to the user control by using public properties as you have seen in the code above. But i need to know if the delete was successful or not.
Can anyone help and advice me on this. code examples would be most grateful.
Many thanks,
Steve
|
|
|
|
|
Why don't you create a method yourself that will check whether the task can be deleted. If it can it will return true and set the specific property with the correct information. If the method returns false then the property will be unchanged and you will be able to tell whether the deletion was successful or not.
Regards,
Thomas Stockwell
Programming today is a race between software engineers striving to build bigger and better idiot-proof programs, and the Universe trying to produce bigger and better idiots. So far, the Universe is winning.
Visit my homepage Oracle Studios[ ^]
|
|
|
|
|
Hello,
Thanks for your help.
The delete button itself is on the user control. So making a method that will return true or false in the user control itself, wouldn't do any good. As the parent would not know if the delete button has been clicked or not.
Its a bit like having a child form and clicking on a button on the child form. How would the parent form know if a button had been clicked on the child.
Steve
|
|
|
|
|
It sounds like you could setup an event system between the two controls. When the delete button is pressed set off an event that the parent will listen for. Then when the parent recieves the event notification then you can check the method of the usercontrol for true or false.
Regards,
Thomas Stockwell
Programming today is a race between software engineers striving to build bigger and better idiot-proof programs, and the Universe trying to produce bigger and better idiots. So far, the Universe is winning.
Visit my homepage Oracle Studios[ ^]
|
|
|
|
|
Hello,
Once again thanks for your reply.
It sounds like that will work. However, I am not sure how to put that in code. An article where this is done would be very helpful if you know any. I would like to learn more about this.
Many thanks,
Steve
|
|
|
|