Thanks, Dave. I'll consider it.
Ismael_1999
Posts
-
C# and Excel -
C# and ExcelI know Excel reasonably well, but I know only the basic of DataGridView. Excel is installed, and also, if I want other people to see the data, Excel is more appropriate.
-
C# and ExcelHi, OriginalGriff. I don't have the intention of using Excel as a DB. In fact I use SQL Server. Excel is only a way of showing results in a pleasant way. At this time I use Interop Excel interface, but it's very difficult to find the commands and its variations. If you know a way of getting the library of these commands, I'd appreciate to know it. Thanks.
-
C# and ExcelHi, Dave. I search for an easy to use interface with a relation of the available commands. I know Excel reasonably well and want to create visually good sheets. Do you have any suggestion?
-
C# and ExcelHi. I'm working with Visual Studio 2022 and I have an application that uses excel. I'd like to know your opinion on the interfaces available: Interop, ClosedXML or any other. Which one is the best? Thank you.
-
C# Enable or disable menu in a form frm another formOnce again you help me, OriginalGriff. I'll Think about. Thanks.
-
C# Enable or disable menu in a form frm another formOk, Richard. I'll try it. Thanks
-
C# Enable or disable menu in a form frm another formI have an application developed in Visual Studio 2022 that works with forms. In this application, there is a main form, from which other forms can be opened. In this main form, there is an item in the top menu (“selection”), whose name is M_Selecao, which must be activated or deactivated depending on which form was opened. For example, when the “Expenses” form is opened, the menu must be activated (enabled). When this secondary form is closed, the “selection” menu must be disabled. I can enable the menu, but I can’t disable it. I tried to make the main form’s menu “public” in the “TelaPrincipal.Designer.cs” file:
public System.Windows.Forms.ToolStripMenuItem M_Selecao;
This way I could disable the menu in the main form when closing the secondary form, but I get the message that "an object reference is required for the method or property 'TelaPrincipal.M_Selecao'. I also don't know how to do it from the main form. Can anyone help me? Thanks.
-
C# config file stopped workingHi, Richard. Your assumptios are correct. Notice that users had access to the program and everything was fine. The configuration program (which is used to change parameters in config file) also worked without problem in my computer and in the other computers. After I made some changes (I remove one parameter) both programs stopped working in the other computers, but continue to work fine in mine. Maybe, as you say, some permissions were changed, but I have no idea of what was it. What do you suggest me to see in that article? Thank you.
-
C# config file stopped workingHi, everyone. I´ve developped a C# program and I have a problem with configuration file. I use Visual Studio 2022 and Windows 10. To start, the program acesses the configuration file to read some information, then, after the user enters username and password the program grants (or not) use and opens main screen. In config file there are information about server name and DB name. Everything worked fine until some days ago. I made some changes in config file (I removed a variable) and, in my computer it works, but in another computer it does't anymore.An exception appears about connection to DB which is closed. After many prints I foud out that the program is using variables not from the config file, and I don1t know where it comes from. I have also another program which deals with this config file. This file also can't access config file correctly. Here is a snippet of the code of this second file:
ExeConfigurationFileMap fileMap = new ExeConfigurationFileMap();
fileMap.ExeConfigFilename = Base.caminho + Base.nomeArquivo + ".exe.config";
Configuration config = ConfigurationManager.OpenMappedExeConfiguration(fileMap, ConfigurationUserLevel.None);
string Banco = config.AppSettings.Settings["Tipo"].Value;
string Servidor = config.AppSettings.Settings["Servidor"].Value;
string Empresa = config.AppSettings.Settings["Empresa"].Value;
string Local = config.AppSettings.Settings["Local"].Value;
string Diretorio = config.AppSettings.Settings["Pasta"].Value;
MessageBox.Show("Arquivo de configuração = " + fileMap.ExeConfigFilename + "\nServidor = " + Servidor + " Empresa = " + Empresa + " Local = " + Local +
"\nDiretório = " + Diretorio + " Banco = " + Banco);
if (!VerificaBasedeDados(Banco))
{
MessageBox.Show("Base de dados " + Banco + " inexistente!");
return;
}In the first MessageBox.Show, the variable Banco (which is the DB name) is different from what is in the config file! The 'if' after tests if the DB exists, but the program crashes before it. The curious thing here is that in my computer it runs OK. In other computers it doesn't (I tried in 2). And before that change it ran OK too! I tried to include back the variable but it didn't work. Does anyone have any ideas? Thanks.
-
Program instalator in C#, Visual StudioI've finished an application in C# using Visual Studio 2022 and need to make an installer for it. I used Microsoft Visual Studio Installer Projects extension and could create the installer which works fine. But I need something else: during instalation, it's necessary to create a folder, then a file and save this file into that folder. But I don't know how to do this in this installer. Does anybody has a solution for this? Thanks.
-
Changing Windows registry with C#Hi, Dave. I changed my approach. Now I get a special folder path and will use it to store a text file containing the installation folder of my app. The command is:
string caminho = Environment.GetFolderPath(Environment.SpecialFolder.CommonApplicationData).ToString();
I think it will solve my problem. Thanks for your help and interest!
-
Changing Windows registry with C#I'm writing a program to control incomes and expenses of a small company. .NET Framework version 4.8.04084. Microsoft Visual Studio Community 2022 Version 17.2.6 Is this what you wanted?
-
Changing Windows registry with C#Hi, Eddy. How can I obtain the installation folder of an application? Note that I need it from another application, not the one running at this moment. Thanks.
-
Changing Windows registry with C#Dave. For me there is no GUID box. But I'll tell yu my original problem, and maybe you can give another tip. I'll install a desktop application for a client and need to store the instalation folder somewhere. Inicially I thougt of using windows registry, but the local available was CURRENTUSER, and I didn't like it. Then I read OriginalGriff's article and thougt of a text file anywhere I can find and the ALLUSERS folder appeared to be good for me. Then these problems arouse. Do you have any suggestion? Thanks a lot.
-
Changing Windows registry with C#Hi, Dave. I tried here, but didn't get it. I use VS Community 2022 in portuguese. In my superior menu there is "Tools" and then "Create GUID". Next appears a small form with many options (1 - IMPLEMENT_OLECREATE(...) 2 - DEFINE_GUID(...) and others). Menu says I must copy and paste the chosen option in my source code. But I don't understand what I should do. Have you seen this? Can you help me? Thanks again.
-
Changing Windows registry with C#Hi, OriginalGriff. I used the code you wrote in your article, but I received an error message. First see a snipet of my code:
public static Guid AppGuid { get { Assembly asm = Assembly.GetEntryAssembly(); object\[\] attr = (asm.GetCustomAttributes(typeof(GuidAttribute), true)); return new Guid((attr\[0\] as GuidAttribute).Value); } }
This is in fact your code. The error is on the line of the return: "System.IndexOutOfRangeException: 'Index was outside the bounds of the array.'" Do you know what causes this error? Thanks.
-
Changing Windows registry with C#Hi, OriginalGriff. I read your article which you suggested and I'll probably change my storage place. On question: your article is 10 years old. Are those information still valid? Thank you.
-
Changing Windows registry with C#Thank you Dave, but code should run without user intervention.
-
Changing Windows registry with C#Hi. I'm working with Visual Studio on a application that changes a windows registry. There is a small forms that requests an address in a text box. The contents of the text box wil be writen is the registry. I need the key to be LocalMachine and here is a snippet of this code:
private void button1\_Click(object sender, EventArgs e) { RegistryKey chaveBase, chave; chaveBase = RegistryKey.OpenBaseKey(RegistryHive.LocalMachine, RegistryView.Registry64); chave = chaveBase.CreateSubKey("Software\\\\Antares", true); chave.SetValue("Endereço", textBox1.Text); }
The problem is that I receive the message: "System.UnauthorizedAccessException: 'Access to the registry key 'HKEY_LOCAL_MACHINE\Software\Antares' is denied". If I change LocalMachine for CurrentUser, it works fine. What should I do to access LocalMachine?