Relative Content

Tag Archive for c#winforms

How to disable TAB key in ContextMenuStrip?

I have a simple and old windows forms app with a MenuStrip and ContextMenuStrip and I need that the TAB key doesn’t iterate thru the items, it has to be just the arrow keys.

How to disable TAB key in ContextMenuStrip?

I have a simple and old windows forms app with a MenuStrip and ContextMenuStrip and I need that the TAB key doesn’t iterate thru the items, it has to be just the arrow keys.

How to disable TAB key in ContextMenuStrip?

I have a simple and old windows forms app with a MenuStrip and ContextMenuStrip and I need that the TAB key doesn’t iterate thru the items, it has to be just the arrow keys.

Cant set variable in winform

For some reason, my variable(which holds multiple variables) in my Updateform can’t be set to any value whatsoever[It keeps coming up null when it is getting sent information(I did it in multiple ways, so I am 100% sure I am sending what I need)], This is weird as I previously set a string on the previous form I opened, Using the same method I used on this one.

ConfigurationManager and config files

I’ve created a project in c# using windows forms and wanted to use a config file (App.config) containg information about what database to use, what language it is and so on but it doesn’t matter for now. So everything works perfectly fine when I run the program from inside of visual studio. The problem begins when I tried to test it on other machine. It turned out that ConfigurationManager tries to access the path to App.config instead of project.dll.config so it takes the path from my computer which of course doesn’t work on other computers.
Another thing is that I found information that it should actually be project.exe.config but I wasn’t able to change it and my project generates only said “project.dll.config”. Is it ok?
I tried to use chatgpt to help me solve the issue or even ask the right questions but no luck. I dug the web but again no luck.
I have a standard instalation of visual studio 2022, no plugins or anything. I also haven’t modified anything in the general options of VS (so treat it as a fresh installation).

How do I make data from another form available?

I am working on a ERP system and I want to make multiple use Tool Strip Bar look like thisenter image description here
The buttons on the Tool Strip can control the events on other forms(I set the Tool Strip on main form) so the buttons can control functions like add data, save data, edit data, delete data.

Stop form from Closing

In my application, When I click the submit button on the MainForm, the Please Wait form appears, which shows untill the processing is complete. The submit button redirects to Books.cs. When someone accidentally clicks the Close(X) sign on the main form(MainForm.cs), the form is closed but the execution is not terminated, the please wait form continues to show and completes the process. It is because the processing is done on a different thread. I want to prevent the user from closing the MainForm when the processing is in progress.
My issue is that e.Cancel does not seem to be working. I can still close the mainform. I tried to set the breakpoint on the mainform form closing event, but that breakpoint never hit.