|
Hello people,
I have made a CheckedListBox,
now is my issue here is my code
Public Sub SQL_Columns_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
MyCbList.Items.Add("Owner", CheckState.Checked)
MyCbList.Items.Add("Translator", CheckState.Checked)
MyCbList.Items.Add("Order number", CheckState.Checked)
MyCbList.Items.Add("Quotation number", CheckState.Checked)
MyCbList.Items.Add("Area", CheckState.Checked)
MyCbList.Items.Add("Description", CheckState.Checked)
MyCbList.Items.Add("Order date", CheckState.Checked)
MyCbList.Items.Add("Delivery date", CheckState.Checked)
MyCbList.Items.Add("Source langugage", CheckState.Checked)
MyCbList.Items.Add("Target langugage", CheckState.Checked)
MyCbList.Items.Add("No hit", CheckState.Checked)
MyCbList.Items.Add("Words(75-84)", CheckState.Checked)
MyCbList.Items.Add("Words(85-94) ", CheckState.Checked)
MyCbList.Items.Add("Words (95-99)", CheckState.Checked)
MyCbList.Items.Add("Words (100%)", CheckState.Checked)
MyCbList.Items.Add("Words (repetitins)", CheckState.Checked)
MyCbList.Items.Add("Words (CM)", CheckState.Checked)
MyCbList.Items.Add("Words (Total Words)", CheckState.Checked)
MyCbList.Items.Add("DTP", CheckState.Checked)
MyCbList.Items.Add("Ext.hr", CheckState.Checked)
MyCbList.Items.Add("Int.hrs", CheckState.Checked)
MyCbList.Items.Add("Cust. Invoiced", CheckState.Checked)
MyCbList.Items.Add("Estimated Customer Total", CheckState.Checked)
MyCbList.Items.Add("Estimated TB", CheckState.Checked)
End Sub
I wonder how do I make item to a string if the item is checked?
thank you in advance
|
|
|
|
|
This should work in .NET 4.0 or higher:
Dim theCheckedItems As String = String.Join(Environment.NewLine, MyCbList.CheckedItems)
If you're using .NET 3.5, then you'll need to convert the collection to a string array:
Dim theCheckedItems As String = String.Join(Environment.NewLine, MyCbList.CheckedItems.Select(Function(item) Convert.ToString(item)).ToArray())
"These people looked deep within my soul and assigned me a number based on the order in which I joined."
- Homer
|
|
|
|
|
So I have a Windows Form Program that writes a serializable class to a binary file, to store SMTP server information. The goal is to store data that both program can use. One program writes the data and the other program, the service consumes the data.
I tried registry, but since the Windows Form program runs as a user, and not a service account, I can't really access the correct registry key in HKEY_CURRENT_USERS.
So I thought, OK, I'll write the data to a file, so the service can read it. But after hours of trying to learn how to debug OnStart, and finally able to do it, the service can't read the file that the Windows Form app wrote, a security issue; versions don't match.
So now I tried moving the Serializable class to the 3rd program, the web service, and placing it there. Figuring that the 2 program can just use the class in the Service Reference for the Web Service. Only the serializable class won't publish unless I use it in the Web Service.
I read there was a way to use Version1Type, and Version2Type so that several programs can share the data files, but it doesn't seem to exist in System.Runtime.Serialization.
I guess I could write a XML file, but that's a lot of work. I really like the binary data file. But can't figure out how to match the versions. I'm using 4.5
|
|
|
|
|
Serializing to an XML file is a lot of work? On which planet? It's actually really easy to do.
Here[^] and here[^].
Put the classes that you serialize into a 4th project which all of your other projects reference. This will keep the full type name of the classes consistent and the versions won't change as you modify the programs. You can also put the file under the CommonApplicationData (Environment.GetFolderPath) folder for a nice place that every application in this project can get to. It'll resolve to C:\ProgramData. Stick your files in a folder under there.
|
|
|
|
|
I was thinking last night just put the file io and serialization classes in a 4th project DLL, and just have the 2 windows programs reference it.
I was aware of saving the serialized classes as XML, but I was on another planet, looking back at earth after trying to debug the web service. I didn't know it would be that easy to do.
I'll look into changing where I save the files, right now, I saved them in the Program files folder for the project.
I'll give it a spin today and see what happens.
Thanks Dave
|
|
|
|
|
Yeah, everything under Program Files is read-only to users. Not a good place to write data at all.
|
|
|
|
|
I didn't know it was read only, good call on making that comment, thanks!
Now I have 7 projects in my solution. It's getting complicated to just send promotional emails.
But I was able to write the file in the Win app, and read it in the Win Service using the Common DLL that I just wrote. So now I guess I might as well centralized all the shared stuff, to make it easier to update and keep track of, and dump the registry storage for the Binary files. And move the Service Reference to the Common DLL and the Soap calls as well.
Thanks Again Dave!
|
|
|
|
|
I'd recommend using a file-based database, like SQLite. Easiest way to prevent versioning-problems with serialization, is not to use serialization.
Bastard Programmer from Hell
If you can't read my code, try converting it here[^]
|
|
|
|
|
That's a good idea, but I already wrote a Web Service for the web site that the programs access data for. Hard to explain, but the windows programs access a website web service that in turn access the database server for data. The Serialization binary files store the web service location and credentials and the mail server location and credentials.
I was trying to avoid using another database server.
I'll try a 4the project today and integrate common code into it, that both windows programs can use to access common features.
I'll give it a spin right now.
Thanks Eddy!
May be back today.
|
|
|
|
|
jkirkerx wrote: I was trying to avoid using another database server. SQLite, SqlCe and Access aren't servers; with SQLite having a very small footprint and being available on multiple platforms
jkirkerx wrote: I'll give it a spin right now. You're welcome
Bastard Programmer from Hell
If you can't read my code, try converting it here[^]
|
|
|
|
|
I guess your advice is probably the better advice.
I'll write a general post in my thread.
|
|
|
|
|
So I wrote a commmon DLL and moved all the common stuff over to it.
Now I get a Access Denied from the Folder
c:\ProgramData\redCopper\smtpMessenger\ and not the serialized binary file.
I wrote a text file to the folder, and set the code to open it, got the same error.
I thought in theory, I would be able to write to it from the Windows Form App, which works and read it from the Common DLL, that represents the Windows Service, Which doesn't work.
So I wonder if it's because I had to elevate VS 2013 To Administrator, to debug the Windows Service OnStart Event. The Windows Service runs on Local Account
Dim m_appPath As String = Environment.GetFolderPath(Environment.SpecialFolder.CommonApplicationData) & "\redCopper\smtpMessenger\smtpCredentials.bin"
Try
Using fs As New FileStream(m_appPath, FileMode.Open)
Dim bf As New BinaryFormatter()
pResults = bf.Deserialize(fs)
End Using
|
|
|
|
|
Users are, by default, not allowed to write to "ProgramData", only admins. It is an admin that installs the application, and any shared files it needs to read. Data is saved somewhere else; it is not part of the installation-package, and since it cannot be reinstalled, it must be in a location that is backed up regularly.
When running under the users' credentials, it will not be allowed to write there; alternatively, you can write to the "public" documents folder. All users should have access to that one (documents and settings\public\etc).
See this[^] page.
Bastard Programmer from Hell
If you can't read my code, try converting it here[^]
|
|
|
|
|
I see why you suggested the SQ Lite, you had the foresight of knowing I would run into this.
My post time was the end of the day, and I should of done more research on storing data.
I could of sworn that I read that Program files had read write permissions for any program installed in that folder since Vista, but I haven't updated my knowledge since Windows 7.
I'll try Public today and see how that goes.
Thanks Eddy!
|
|
|
|
|
jkirkerx wrote: I see why you suggested the SQ Lite, you had the foresight of knowing I would run into this. Rereading the question I had the feeling we had a similar problem, so yes, been there*. I tend to stick almost everything in a SQLite .dat file, from resources and sprocs to assemblies. Makes stuff easy to copy and mail, makes stuff easy to update. And best of all, there is SQL to separate the data from the rest of the app, so I won't spend much time on writing code for that infrastructure.
jkirkerx wrote: I haven't updated my knowledge since Windows 7. Neither have I, but I will be installing any later stable version that has a good price/value ratio.
*) A few times
Bastard Programmer from Hell
If you can't read my code, try converting it here[^]
|
|
|
|
|
What a pain in the A??.
I was looking at other windows services loaded on my machine, and noticed a few that used the Windows user account to run as. So I figured I'll give that a try.
Easier said than done. Installing the service as a user with a password was much harder than I thought. So I ended creating a new console app that can run as a Windows service, and used some new stuff out there referred to as a Custom Service Base, Custom Service Installer and IServiceLogic and TransactedInstaller. Pretty slick now. The service can self install and uninstall, can be debugged pretty easy now. In fact its so nice, I should publish an article on it.
So I just performed my i/o test, using the common DLL file that now does all the I/O for both programs, the SOAP calls to the Web Service, And the reading and writing of my serialized class files that store parameters, which is now located in the AppData folder of the user account (LocalApplicationData) and it worked without any errors on all 3 programs. No more folder errors or binary read errors from the creator assembly.
So now, I since I wrote a new service, I might as well trick it out, and make it better and more up to date, guess I'll write some threads that the service can run to do it's gig.
I was smart enough this time to make a copy of the project, in it's sort of raw form that just supports install and uninstall and debug, with no other logic in it.
Thanks Dave and Eddy for the help!
The Link to the Service code that I used
Creating easy to debug Windows Services in .NET - CodeCaster.nl - Blog[^][^]
|
|
|
|
|
I have used two forms and one form open to showdialog condition...
while showdialog closing at the same time need to another form closed...this is my problem so please solve this..........
|
|
|
|
|
On return from ShowDialog you can close the form.
|
|
|
|
|
I need vb.net project on finance marketing please get me the working project
|
|
|
|
|
|
Code Project is not a "code-to-order" site. If you want a completed projects, go pay for it at Freelancer.com. Oh, and I hope you're not picky about the quality of the code.
|
|
|
|
|
Hai All,
How to change PC Time format in application loading time
very Urgent.......pls reply
Thank you
regards,
Dha Na
|
|
|
|
|
|
I need to change the System (Control Panel-->Regional Setting-->Short Date Format) Date through VB.Net code.
|
|
|
|
|
|