winforms | Windows Forms is a .NET UI framework | Form library
kandi X-RAY | winforms Summary
kandi X-RAY | winforms Summary
Windows Forms is a .NET UI framework for building Windows desktop applications.
Support
Quality
Security
License
Reuse
Top functions reviewed by kandi - BETA
Currently covering the most popular Java, JavaScript and Python libraries. See a Sample of winforms
winforms Key Features
winforms Examples and Code Snippets
Community Discussions
Trending Discussions on winforms
QUESTION
In a manufacturing environment, for a specific process, there are fairly straightforward C# Winforms Desktop applications that involve enum-based state machines running on infinite loop, following a structure similar to below (state names kept general for the sake of example).
...ANSWER
Answered 2022-Mar-20 at 18:52If you have multiple states and it is necessary to change behaviour based on state, then we can use strategy pattern combined with factory pattern.
At first, we need to declare states:
QUESTION
This is a code snippet.
FtpDownloader.java
...ANSWER
Answered 2022-Mar-02 at 05:44I think I got what you're trying to do. First of all, FTP doesn't itself let you use multiple connections simultaneously (For ref Uploading files in parallel with Java FTP client).
What you're doing is not thread-safe as well. So I advise you to make parallel connections and download from there.
QUESTION
I am trying to embed WebView2 DLL in a C# project. I have added the 3 DLLs :
...ANSWER
Answered 2022-Feb-24 at 08:24Looks like you have resolved the embedding part of your question and are left with just the deletion of the extracted DLLs.
Because the DLL is inuse but your own process, unless you are able to uload the DLL successfully, I dont think you will be able to delete the DLL.
1st Potential Option
One thing you could try and do is schedule the deletion of the file after reboot. This SO post explains how to do that using P/Invoke and MoveFileEx
.
The example they give is as follows:
QUESTION
Sometimes things (PowerShell?) gets too smart on me...
In this case, I would like change the Text
property of a WinForms ListBox
item selected by its index (not the SelectedItems
). The point here is that $ListBox.Items[$CurrentIndex]
appears to be a [string]
type rather than an [Item]
type...
For this I have created a mcve (with a context menu) out of my bigger project:
ANSWER
Answered 2022-Feb-23 at 13:36You could modify the stored item value with $ListBox.Items.Item($CurrentIndex) = $Text.ToUpper()
- but modifying a collection item in place is not going to trigger re-drawing the ListBox
control, so it'll look like no change took place.
Instead, modify the collection itself - remove the old entry and insert a new one at the same position:
QUESTION
I'm trying to automate a process using PowerPoint from C#, to do this I want to open (or create a new) PowerPoint presentation, add a slide, and save the document.
I've got the entire office 2019 package installed on my machine and can access the ppt api by referencing the Interop.Microsoft.Office.Interop.PowerPoint
(from the Microsoft PowerPoint 16.0 Object Library reference) along with Interop.Microsoft.Office.Core
(from the Microsoft Office 16.0 Object Library reference).
I try to open a powerpoint using the following code:
...ANSWER
Answered 2022-Jan-13 at 21:12It looks like the interop assemblies were generated improperly by tlbimp
at the certain point. You can find that assembly at \obj\Debug\netcoreapp3.1\Interop.Microsoft.Office.Interop.PowerPoint.dll
.
To re-generate it properly, you need to do the following:
- Remove the reference to "Microsoft PowerPoint 16.0 Object Library". Clean and rebuild the project. You may also try unloading the project and removing the
bin
andobj
folders manually at this point. - Add references to both "Microsoft 15.0 Object Library" and "Microsoft 16.0 Object Library".
- Add back reference to "Microsoft PowerPoint 16.0 Object Library", and clean and rebuild the project once more.
After performing these steps, my .NET Core 3.1 WinForms project was compiled successfully.
Here are the contents of the .csproj
file in my case:
QUESTION
This has stumped me for a few hours. I'm rewriting a Winforms desktop app to support an ASP.NET Core website. The app stores some tables locally in a LiteDB cache, and calls a "using" DBContext to get data.
The desktop app uses a TaxAccount
abstract class, which is inherited by Household
and Business
.
On client search, the app calls GetAccount() to display a single user account. Since the DB can be slow, the cache is updated in the background. Here's the method.
...ANSWER
Answered 2022-Jan-11 at 07:14Begins tracking the given entity and entries reachable from the given entity using >the Modified state by default, but see below for cases when a different state will >be used.
Generally, no database interaction will be performed until SaveChanges() is called.
My guess is, that the Account is tracked until the changes are saved.
QUESTION
I'm doing a WinForms app (which I haven't done in a long time) and noticed that in VS 2022, the "view code" button (looks like <>) which used to be on the toolbar on the "Solution Explorer" window is missing. I know I can right-click on a form and reach it through the context menu, or hit F7, but is there any way to add it back? I can't seem to find any option for it.
...ANSWER
Answered 2022-Jan-10 at 23:06Possibly a bug, as mentioned in the other answer, meanwhile, as a workaround you may want to create a VS extension that adds the command to Solution explorer, then set the visibility rule for .cs files. Then in the action of the command, find the selected item and open it with code editor.
Add a button to solution explorer to open .cs files in code editor
This extension adds a toolbar button to the Solution Explore which will be visible, only if you choose a C# file, and when you click on it, it opens the file in code editor:
You can download or clone the solution here:
Here is the step by step guide on creating this extension:
Add new project and choose 'VSIX Project' and leave the default name.
Please note: To have this project type, you need to install 'Visual Studio extension development' when installing/modifying VS installation.Add new item and choose 'Command' which is under 'Extensibility' group.
Open 'VSIXProject1Package.cs' file and add the following line of code to the class:
QUESTION
I need to archive a folder without some subfolders and files using PowerShell. My file/folder exclusions can occur on any level of hierarchy. To explain, here is a simple example for a WinForms VS project. If we open it in VS and build, VS creates the bin/obj subfolders with executable contents, the hidden .vs folder with user settings, and maybe *.user files for the projects included into the solution. I want to archive such a VS solution folder without all those file and folder items that can be recreated the next time when we build the solution.
It is done very easily with 7-Zip using its -x! command line switch:
...ANSWER
Answered 2022-Jan-10 at 19:26This is a similar problem to how-to-compress-log-files-older-than-30-days-in-windows.
The ArchiveOldLogs.ps1 script will preserve folder structure without the need for intermediate copying.
You can change the -Filter
parameter to exclude certain files by name rather than date:
QUESTION
In Windows Forms and WPF applications we could use the Settings designer file to save user-specific settings. The docs only mention .Net Framework (e.g. 1 - 4), not .Net Core or .Net (e.g. 5+). I've confirmed that the .settings format and designer still works in .Net 6 WPF on Windows with Visual Studio 2022 though.
My questions is, is the .settings
file format and designer still the recommended approach for .Net MAUI applications? Will it work across all platforms (Windows, macOS, mobile)? If not, is the recommended approach to simply write your own custom file for saving your user settings, and if so, where should the file be written to? Environment.SpecialFolder.ApplicationData
/ Environment.SpecialFolder.LocalApplicationData
, or somewhere else?
ANSWER
Answered 2022-Jan-06 at 09:20It all comes down to your requirements really. There is no silver bullet to this.
I must admit I didn't really know the settings (designer) file that you mentioned. I can tell that that's not a thing (as far as I know) in Xamarin or .NET MAUI. Probably also because there is the concept of a sandbox in mobile apps that is less a thing on desktop apps. So the location where things are saved are a bit more important.
In the comments there are already a couple of great suggestions to get you started. If your requirement is to just save simple types (string, bool, int, etc.) then the Essentials Preferences API should work just fine. I think under the hood that just serializes to a json file and stores it somewhere. Essentials is indeed already part of .NET MAUI at this time.
Xamarin.Forms used to have their own Properties, which is I think a more common concept in .NET applications, but I think the Essentials way is better.
If you want to save more complex things you might want to consider using a local database like SQLite or just roll your own and serialize your settings and save that somewhere, preferably with the Essentials FileSystem Helpers.
One thing to note here, and that is where the value of these libraries come in, is where you save the settings. Do you want the settings to be backed up to a cloud service so if survives a reinstall of the app? Or even an install of the same app on a new phone? Or do you then just want to reset the whole state and don't care about it.
If you figure that out, the rest is up to you! Hope this helps.
QUESTION
I have a C# Windows Forms application that is referencing a DLL (managed code) that is using SeriLog to log events. The SeriLog logger is defined in the Windows Forms (main) application, so I have control over the type of sink I am using. Currently I am just logging to a local text file.
My question: is there an elegant way for me to view the log in a Listbox or similar WinForms control in real time while the application is running? The only way I can see at the moment is to read the Log file every few seconds and display the latest item. But I am sure there may be a more elegant way to do capture just the last one or two logged items?
...ANSWER
Answered 2021-Sep-03 at 03:01Use FileSystemWatcher
to monitor the file change and then update that Listbox in the OnChanged
event handler
Community Discussions, Code Snippets contain sources that include Stack Exchange Network
Vulnerabilities
No vulnerabilities reported
Install winforms
Support
Reuse Trending Solutions
Find, review, and download reusable Libraries, Code Snippets, Cloud APIs from over 650 million Knowledge Items
Find more librariesStay Updated
Subscribe to our newsletter for trending solutions and developer bootcamps
Share this Page