How to identify Key Combinations ?
CodeProject » C#
by
2d ago
Hello, I was able to identify a key press with a single key by the following code: public override bool ProcessKeyDown(KeyEventArgs e) { if (e.IsRepeat) return false; if (e.Key == Key.Escape) { //do sth } } But I was not able to find a solution that also identifies key combinations like: CTRL + arrowup etc. I also did not find anything that wokred with: KeyEventArgs e Any hints from your side ..read more
Visit website
How to send property values via eventhandler ?
CodeProject » C#
by
1w ago
public class Person : INotifyPropertyChanged { private string name; public event PropertyChangedEventHandler PropertyChanged; public string Name { get { return name; } set { object before = Name; name = value; OnPropertyChanged("Name", before, Name); } } void OnPropertyChanged(PropertyChangedEventArgs e, object? argvaluebefore = null, object? argnewvalue = null, [CallerMemberName] string argcallername = "", [CallerLineNumber] int argcallerline = 0) { //How can I inject argvaluebefore ..read more
Visit website
Read information from serial port in Mathlab format
CodeProject » C#
by
1w ago
Hello I'm using this code from microsoft example but the information that I show from the red of the serial port is printed in ASCII, and I would like see in Mathlab. Please could you help me. THis is the code: using System; using System.IO.Ports; class PortDataReceived { public static void Main() { SerialPort mySerialPort = new SerialPort("COM3"); mySerialPort.BaudRate = 56000; mySerialPort.Parity = Parity.None; mySerialPort.StopBits = StopBits.One; mySerialPort.DataBits = 8; mySerialPort.Handshake = Handshake.None; mySerialP ..read more
Visit website
Debugging the Sandbox
CodeProject » C#
by
1w ago
Has anyone been successful at attaching the Visual Studio remote debugger to any process in the Windows Sandbox VM? I set my Debug Launch profile to start the application on a remote machine, and it successfully connects to the remote debugger process in the Sandbox, but when it tries to launch the application as configured in the launch profile, it says "Unable to start process <PATH to exe>". The problem is that the path that it says it's trying to start is the path on my local machine, and not the path I have configured inside the launch profile to start on the remote machine. Has ..read more
Visit website
IParsable? IFormattable? ICustomFormatter? IFormatProvider? TryParse! ToString!
CodeProject » C#
by
3w ago
I am attempting to write a short program in C# that deals with resistances (in electronics). I would like to be able to parse string values into floating point values. The string can be in the format like 100, 4.7K, 2.2M, or shorthand equivalents like 100, 4K7, 2M2. They should never have more than 3 digits, at least one of which is a whole number part (no more than 2 decimals). Also I would like to be able to display them in similar formats. I've looked into MS documentation, and I'm more confused than ever. When do I need to use (if at all) IFormatProvider, ICustomFormatter, IFormattable, IP ..read more
Visit website
(Current) AI Rant.
CodeProject » C#
by
1M ago
Me, wanting to "peek" the "last" entry in a ConcurrentQueue, because the "next" entry I will enqueue needs "prior info" if it exists. I can use ToArray, and GetEnumerator. Surprising .Last() compiles but I thought I'd "Bing" anyway. Me: peek last entry in concurrentqueue Copilot with GPT-4: Quote: Certainly! In C#, if you want to peek at the last entry in a ConcurrentQueue, you can use the TryPeek method. Here’s an example: (Some "wrong" / right code). Quote: In this example, the TryPeek method allows you to examine the last item in the queue without removing it. If the queue is empty, it ..read more
Visit website
MessageBox Appearing Behind Window
CodeProject » C#
by
1M ago
I'm having a problem with a MessageBox.Show() call. It's being called from a window that was shown with Form.ShowDialog(). The problem is that the message box sometimes appears behind the dialog box, and makes the dialog box unresponsive until the message box window is found and OK is clicked on it. This would be terribly confusing for users. Is there any way to guarantee that a message box is displayed above the form that is calling it? The difficult we do right away... ...the impossible takes slightly longer ..read more
Visit website
Updating sql table where textbox = ID
CodeProject » C#
by
1M ago
I am attempting to update a sql table based off the tables ID (which is self generated by sql when the row was first entered into the table. The below code is what I am trying to use but it will not update the row. protected void ButtonUpdate_Click(object sender, EventArgs e) { SqlConnection con = new SqlConnection("Data Source=ucpdapps2;Initial Catalog=Offline_CAD;Persist Security Info=True;User ID=sa;Password=Propaganda9800!"); con.Open(); SqlCommand cmd = new SqlCommand("Update [Law_Responses] SET (Calltaker=@Calltaker,Date=@Date,City=@City,County=@County,Addre ..read more
Visit website
Creating a shortcut (LNK)
CodeProject » C#
by
1M ago
Hi, I'm working in .NET 8 (not .NET Framework). Trying to programmatically create a file system link (LNK file) in C#. I've added a reference to the Windows Script Host Object Model as detailed in many different online articles. However, I can't seem to find the correct Using statement to import the classes in that reference. When I say, "Using IWshRuntimeLibrary", it says it cannot resolve the type or namespace. What must I do to import the types in the Windows Script Host Object Model reference? The difficult we do right away... ...the impossible takes slightly longer ..read more
Visit website
I want to display both Old and New Values in Form2.
CodeProject » C#
by
1M ago
I have three windows form say form1 ,form2 and pin form.In form1 user have to input some values.There is save button in this page .By clicking on save button Pin form is opened in that we have enter the correct pin and by clicking on submit button form2 get opened.In Form2 the values that user entered in the form1 is displayed in the old values column. And then the user go back to form1 and modify the values and click save button to come to form2. That modified values are displayed in new values column. The problem is that when second time i modify the values in form1 and click save to go to ..read more
Visit website

Follow CodeProject » C# on FeedSpot

Continue with Google
Continue with Apple
OR