Click here to Skip to main content
15,886,137 members
Everything / Programming Languages / C#

C#

C#

Great Reads

by Wonde Tadesse
The other option will be to use Update Panel ASP.NET control as much as possible. It helps to retain the current position on the page whenever a postback happens to the page.
by Alex Pumpet
A simple program for comparing table data from two sources - SQL databases, Excel, CSV or XML-files
by Dr. WPF
.NET 3.5 SP1 is here! It's time to break out your DirectX skills. This article provides the information necessary to get started using a new DirectX interop feature in WPF called D3DImage.
by John Atten
OWIN, Katana and Middleware Pipeline in ASP.NET

Latest Articles

by Nicolas DESCARTES
How to implement authentication in Blazor and ASP.NET Core ?
by honey the codewitch
How to validate fields for things like data entry applications.
by Yevgeniy Shunevych
An introduction to Atata C#/.NET web UI test automation full-featured framework based on Selenium WebDriver
by honey the codewitch
Scraping the web is easy with Visual FA. Here's an example of how.

All Articles

Sort by Updated

C# 

U 25 Apr 2024 by G Schulz
I am trying to make a simple macro thing, I want it to record messages such as the mouse inputs, but also things like page select. I plan on saving these into a list or array, and then just looping over them and sending to the computer. I am...
N 25 Apr 2024 by Member 16239100
namespace DataGridDragSelectExample { using System; using System.Collections.Generic; using System.Diagnostics; using System.Linq; using System.Windows; using System.Windows.Controls; using System.Windows.Controls.Primitives; ...
N 25 Apr 2024 by Pete O'Hanlon
There are two parts to this problem if you are keeping it simple, and assuming that your datagrid is entirely viewable in one screen. The first thing you need to consider is how to draw a selection rectangle. There's an article here[^] that...
N 25 Apr 2024 by Member 16239100
I want the datagrid rows to be selected using a selection rectangle like we do in win File explorer Can anyone please tell me how to make this kind of behaviour in our own WPF app. Right now i am making a File explorer kind of behaviour using the...
U 24 Apr 2024 by Ignatius Baron Rio
using System; using System.Collections.Generic; using System.Globalization; using System.IO; using System.Linq; using System.Text; using System.Threading.Tasks; using System.Windows.Data; using System.Windows.Media.Imaging; namespace...
N 24 Apr 2024 by Nicolas DESCARTES
How to implement authentication in Blazor and ASP.NET Core ?
N 24 Apr 2024 by Graeme_Grant
I did a quick Google Search wpf datagrid multiselect dragging with scroll[^] and found this working solution: DataGrid auto scrolling when doing selection - solved[^]
N 24 Apr 2024 by Graeme_Grant
This is a common question so I did a quick Google Search that many solutions for your question: winform trasparent image overlay[^]. Pick one that best suits your needs.
N 24 Apr 2024 by Golden Basim
i want show an image that contains png logo, this image must be transparent as it over another control (Camera Control). What I have tried: I tried this solution but the issue that the Image (in Transparent control) appears in back of the...
N 24 Apr 2024 by GabrieleTronchin
Some years ago, I had to implement an OPC UA Client and server with .NET. Here are some steps from my journey that may help you: - Nuget packages available are not working as expected. Use the source code directly from GitHub. - The first test...
N 24 Apr 2024 by Jens Madsen, Højby
Fixed: To get a pointer to the first char (or whatever), use 'Marshal.UnsafeAddrOfPinnedArrayElement(Buff, 0)' I believe that using GCHandle to pin 'Buff' isn't needed on a local variable, but you'd better check it!;)
N 24 Apr 2024 by Member 16239100
I want a WPF datagrid which can select the rows same as we can do in Win explorer. For the i have implemented some code and need some help in that. Here the autoscroll for up direction is working fine but for downside autoscroll its not working....
N 24 Apr 2024 by honey the codewitch
How to validate fields for things like data entry applications.
N 24 Apr 2024 by Graeme_Grant
Maybe that is not the best way to do what you want. Have a look at the free options in this google search: winform free pdf viewer - Google Search[^]
N 24 Apr 2024 by Golden Basim
MySQL Database contains huge data (more than 5Gb) and more than 300,000 of records in some table. Some Queries require to handle some of fields value before showing it to the user like this query : var pQuery = DB2.sales_main ...
N 24 Apr 2024 by PKlaus17
I did a WinForm application to view PDF files. I use WebView2 of Microsoft and CoreWebView2.Navigate(pdfFile). The PDF - file ist displayed fine, but I have problems if the PDF file has several pages. It shows me the first page and I get...
N 24 Apr 2024 by M-Badger
Assuming that you wish to change which function is called for different joystick inputs based on a configuration file then you could use something like the code shown below. You might want to try a more elegant solution if there are a lot of...
N 23 Apr 2024 by sdecorme
HI, Actually I've made a winform application that read buttons and axis of my joystick. My goal is to have a config file to set input list with functions list. for example I'm using Sharpdx but I can change if needed Clear = buttons1 Left =...
N 23 Apr 2024 by Member 16250042
Not working about js. $(document.ready(function () { $(window).bind('beforeunload', function () { $.ajax({ url: "SignOut.aspx", }); }); }));
N 23 Apr 2024 by Member 14770314
This only addresses code behind code. There is no solution for event handler or command handler that lives in a databound ViewModel. No solution for that. It forces code behind and not View Model implementation, or at least a partial mvvm solution.
U 23 Apr 2024 by Yevgeniy Shunevych
An introduction to Atata C#/.NET web UI test automation full-featured framework based on Selenium WebDriver
N 23 Apr 2024 by M-Badger
I've not tested this but it would appear that the MS interop library version that you are using doesn't know how to convert images into MathML or LaTeX format. So either you need to convert them to MathML or LaTeX in the document before saving...
N 23 Apr 2024 by Member 16249553
0x00, 0x00, 0x00, 0x00, 0x78, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,...
N 22 Apr 2024 by Member 7920931
Get element clicked in a canvas. myCanvas.MouseLeftButtonDown += OnMouseLeftButtonDown; private void OnMouseLeftButtonDown(object sender, MouseButtonEventArgs e) { var layer = (Canvas)sender; var element =...
N 22 Apr 2024 by Member 16249372
public async Task>> GetStates() { return await _context.States.ToListAsync(); }
N 22 Apr 2024 by Pete O'Hanlon
It's been a while since I've done this but I'm pretty sure you are going to have to do stream.Seek(0, SeekOrigin.Begin); once you instantiate it.
N 22 Apr 2024 by AAKASH R from Unknown
VLV paginated group search not working in server. What I have tried: I use C# directoryServices to fetch it. when I implemented it I found that it was working find in windows 2022 server and the same was not working in windows 2019 server. It...
N 22 Apr 2024 by OriginalGriff
There are a few problems here. With your existing code, you need to re-think it as the documentation[^] is very clear: Remarks: You must keep the stream open for the lifetime of the Image. Since your stream is created and no reference to it is...
U 22 Apr 2024 by Ravi Bhavnani
After you set the Label controls' text, call Application.DoEvents();.� There's no need to call .Refresh() on the Label controls. Warning: The Form's message pump will respond to all events when executing Application.DoEvents();, including...
U 22 Apr 2024 by sami alhassan
Dear Sirs I am self learning to C# I am doing a project for Assets management I create user control showing two images (QRCode with BarCode) all ok ad these 2 images saved to sql DB by byte.but when I want to display them in the usercontrol only...
N 22 Apr 2024 by Avinash Korat
Here below is my code in which i try to update label controller which is directly placed inside a Form. I want it to be update after every single second. For that i suspend and resume the layout. But still it isn't updating any data on the...
U 22 Apr 2024 by Conduct dotnet
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the...
N 21 Apr 2024 by Member 16248063
there is 3 step in my solution: ---- first: create a helper that stringify the partial views so we can use them in the action method for passing it with json response to ajax. public static class PartialViewHelper { public static string...
N 20 Apr 2024 by honey the codewitch
Scraping the web is easy with Visual FA. Here's an example of how.
N 20 Apr 2024 by Graeme_Grant
So the issue is the uniqueness of the key. Using a dynamic object is the cause of your issue. Each object is unique. This is easy to demonstrate. Create two instances of a class with the same values, then do a comparison. You will find that they...
U 20 Apr 2024 by Golden Basim
I need to get the latest purchases cost for every group based on Item , supplier, unit. and synchronization it to another location .. item 1, pack, Jone, ... item 1, pack, Mich, ... item 1, pack, Yasser, ... item 2, pack, Jone, ... item 2,...
N 20 Apr 2024 by Graeme_Grant
Like desktop apps, you should use multiple techniques to capture and handle errors in your app. Blazor is no different. This page lists a number of strategies that you should be using: Handle errors in ASP.NET Core Blazor apps | Microsoft...
N 20 Apr 2024 by Prasad Sathe
Data not loading on page refresh in blazor webassembly standalone app What I have tried: I have created a sample web app in blazor as webassembly standalone app, then I simply published this web app in a local folder and hosted it in the iis as...
U 19 Apr 2024 by Gerardo Gamo
I know this is very OLD, but NOW myself Im struggling with helping a project that of course also is very old, but anyway, as they are using Web forms or ASPX, here is what I have for anyone having the same issue 1. when working with ASPx, I...
U 19 Apr 2024 by Member 14224038
Hello, what is the best way to get previous character in A-Z, i am having some APIs that return character say 'E' & am thinking to write a function that will return me 'D' ( previous charater) is there any direct function in c# that returns...
N 19 Apr 2024 by Pete O'Hanlon
To add to the answers given above. You should never limit your code to just consider the latin alphabet; there are so many cases where you need to consider international users. Fortunately, this is very simple to cater for. In the following...
N 18 Apr 2024 by Richard Deeming
Given a char, you can subtract 1 to get the previous code-point: char input = 'E'; char output = (char)(input - 1); // Contains 'D' You just need to decide what range of characters you want to support, and validate that the input is within...
U 18 Apr 2024 by OriginalGriff
Yes: subtraction ... using System; public class Program { public static void Main() { string str = "Hello World"; foreach (char c in str) { Console.Write((char)(c - 1)); } Console.WriteLine(); } }...
U 18 Apr 2024 by Test Mail May2023
using System.Text.RegularExpressions; public class RegexStringReplace { public static string? Replace(string input, string rxPtrn, string rxSubPtrn, string value) { // Create a Regex object with the given pattern Regex...
N 18 Apr 2024 by OriginalGriff
I'm not sure what you mean by "I have no idea how to implement this method." since you clear have implemented it and got exactly what I would expect from that when it runs. So I can only assume that the example you give isn't representative of...
N 18 Apr 2024 by dzadel
Hello everyone. Let's say I need a C# method with the following signature: static string? Replace(string input, string rxPtrn, string rxSubPtrn, string value); The method replaces, for each input string that matches a regular expression pattern...
U 17 Apr 2024 by Zijian
Reusable codes for JWT security in business applications
U 16 Apr 2024 by Mishael Ogo
A look at a simple SQL builder for Dapper
N 15 Apr 2024 by OriginalGriff
To add to what Dave has said, the session is a Server side construct, not Client - so it's expiration is unrelated to user input unless that input directly causes the Client browser to send (or request) information from the server. Just moving...
U 15 Apr 2024 by Jo_vb.net
A workaround (not a solution) for improving two of the remaining issues: For private void SelectItemsInRectangle(Rect selectionRect, DataGrid dataGrid, object sender, MouseEventArgs e) you should use the version which was posted here as...
U 15 Apr 2024 by Dave Kreskowiak
Quote: i set the idle timeout for 2 minutes, ... then the session getting expired in 2 minutes It's doing exactly what you told it to do! You said expire the session in 2 minutes, so the session is expiring in 2 minutes. What did you think was...
N 15 Apr 2024 by sysproteam123@gmail.com
Hi, I am working on .Net Core 6(MVC) web application, i set the idle timeout for 2 minutes, when i am moving from one page to another page then the session is working correctly, but when i am staying on any particular page and i am moving the...
N 15 Apr 2024 by Andre Oosthuizen
As Richard mentioned above, you have no code showing how you are going to loop through the mail items. You also need the 'Outlook.Items' and 'Outlook.MailItem' objetcs for it to work properly. Normally I will not show pointers with as little...
U 15 Apr 2024 by Member 15418280
I want to read email from outlook in excel macro i want to add some filter for fetching email like subject from date etc. What I have tried: I tried condition but not working below is the code. Public Sub CheckEmail_BlueRecruit() '...
N 15 Apr 2024 by Graeme_Grant
If you are using data binding, like in this article here: Data binding a ListView[^], then the ListView control becomes a view of the data, not the data container itself. Then you only need to show the properties as columns, as required. This...
U 15 Apr 2024 by Ismael_1999
I need to create a list view with 3 columns, but I need also 2 more columns with related data that should not be viewed. Is there a way to do this? Thank you. I use Microsoft Visual Studio 2022 and this application is in Windows Forms. What I...
N 14 Apr 2024 by Pete O'Hanlon
As an alternative to Ravi's answer, there is a quick and dirty "hack" that you can use, assuming you are using Windows Forms here. When you add an item into a listview, you are adding an instance of a ListViewItem. This class has a Tag property...
N 14 Apr 2024 by honey the codewitch
Implementing a simple JSON parser with Visual FA
N 14 Apr 2024 by M Imran Ansari
In addition to Solution-1, it's advisable to explore further on your own. It's likely that the `lastUpdate` column might contain some null values, triggering exceptions during calculations. You can also try to modify query handle this scenario by...
N 14 Apr 2024 by Ravi Bhavnani
There's no standard way to do this in Windows Forms. The alternative I use is to manage a ListView's configuration in another object and initialize and populate the ListView appropriately.� See this screenshot as an example:...
U 13 Apr 2024 by Member 14224038
Hello, need help in adding objects in dictionary, so when there is new object i am adding key & object but struggling with object because i cant cast it or am doing something wrong ? & it already has the key am appending value to list on same...
U 13 Apr 2024 by SproketCoder
I've been attempting to retrieve a table from the SQL DB based on user inputs, but I'm encountering the following error: "Format of the string does not conform to specification starting at index 0". The query I'm using is "SELECT * FROM...
N 12 Apr 2024 by OriginalGriff
Your command string is wrong: SELECT * FROM @Tablename WHERE Created_On >= '@StartDate' AND Created_On
N 12 Apr 2024 by OriginalGriff
Without your data and some idea what the error message is (and the actual data that generates it) we can't help you - and you have to remember that we can't see your screen, access your HDD, or read your mind - we only get exactly what you type...
U 12 Apr 2024 by Member 11400059
Hi I have lambda query for get all of my record change in more then 7 days ago. my query is: var result = db.adss.Include(i => i.AdsTpyeFK).Where(i => i.updateFlag == true && i.AdsTpyeFK.name == "gold" && (DateTime.Now - i.lastUpdate).TotalDays...
N 12 Apr 2024 by Richard Deeming
Further to Pete's excellent answer, you can use the TryGetValue method[^] to avoid the double key lookup of ContainsKey followed by the indexer: if (!uniqueComp.TryGetValue(cmp1[i].name, out List list)) { list = new List(); ...
N 12 Apr 2024 by Pete O'Hanlon
Your code should look something like this:if (!uniqueComp.ContainsKey(cmp1[i].name)) { uniqueComp.Add(cmp[i].name, new List()); } uniqueComp[cmp[i].name].Add(... whatever the value is ...); Basically, you are testing to see whether you...
11 Apr 2024 by Akram El Assas
Functional Programming in C# through Algebra, Numbers, Euclidean Plane and Fractals
11 Apr 2024 by Andre Oosthuizen
From what I could make out of your code is that your 'SelectItemsInRectangle' method is only considering the visible rows in your DataGrid at the time that you make the selection. When you scroll, new rows become visible, and your selection...
10 Apr 2024 by Jo_vb.net
I think you have to calculate the rectangle position every time when it should move. Perhaps it is simpler to delete the rectangle which is on wrong position and create a new one on calculated position if needed. ...
10 Apr 2024 by Member 16239100
I am attempting to replicate the selection behavior of Windows File Explorer within a WPF DataGrid. Specifically, I aim to implement a selection rectangle that mimics the functionality of File Explorer's selection mechanism. Currently, I have...
10 Apr 2024 by Graeme_Grant
Quote: When Manager clicks either of the link, it hits the endpoint and their response is Captured in Database. To prevent sharing, the only option is for the intended recipient to log back in, then you verify both the account used to sign in...
10 Apr 2024 by Pete O'Hanlon
I'm afraid you need to go back to whoever gave you the requirements and explain this is a monumentally bad idea, and also impossible to implement. If one manager forwards it to another, you can't prevent that, and you can't change the contents of...
10 Apr 2024 by Vaithilingam Alagappan
When User raise a request for Access. User's Manager needs to approve the request through email. The email will have Approve and Reject link as API endpoint URL. i.e., Approve - https://example.com/api/approve, Reject -...
9 Apr 2024 by Pete O'Hanlon
So, what is it that you want to display as an image? The thumbnail that you would see in Windows Explorer? A detailed, scrollable view of the PDF? I'm going to assume that you want the user to actually see the PDF itself here. If this is the...
9 Apr 2024 by PhamLong301
I'm new in C# and I have create a scanner application by C# winform. Now I'm having a problem that when i use treeview for a folder and click in item inside (all items inside are images and pdf file). All image file format display normal in...
9 Apr 2024 by Richard Deeming
Each iteration of your for (int iR = 0; iR
9 Apr 2024 by Aggeliki Asimakopoulou
I have created a back - end application in C# with embedded microsft sql server. I am pretty new to crystal reports and I had created one but in a wrong way and I am trying to correct it. I almost don't remember how I created and I feel bad for...
9 Apr 2024 by honey the codewitch
Generate a web browsable interface to your archived TV show content
9 Apr 2024 by Thomas Schröter
@George: sorry, but StringBuilder IS the PREFERRED way to create strings from data objects. String concatenation is bad due multiple allocating multiple objects in the heap and copying values around. StringBuilder pre allocates a buffer and...
9 Apr 2024 by Member 10371658
I am working with .net core MVC project, in which i set the idle timeout and session expired, it should redirect to the session timeout page, where i am showing message to user, your session is auto timeout, but it's redirecting to the...
9 Apr 2024 by nirmalamari
I entered the right password for the key. But still this issue. is .cert file different from .crt or .cet file
9 Apr 2024 by Dave Kreskowiak
You told the SELECT statement to return only the columns from the Invoices table with the "Invoices.*": SELECT Invoices.* FROM Invoices inner JOIN Customers ON Invoices.custID = Customers.custID where Invoices.custID ... By the way, NEVER use...
9 Apr 2024 by nirmalamari
I am exploring the option to use Okta SAML authentication. Since my evaluation period expired for Okta not able to ask in Okta site, so I thought codeproject forum experts might help. When we register a website in Okta, we get a 509 certificate...
8 Apr 2024 by OriginalGriff
That's some odd code - you only add the button Click event handler if the picture box is clicked: button.Controls.Add(table); panel1.Controls.Add(button); pictureBox.Click += (s, ev) => ...
8 Apr 2024 by Pete O'Hanlon
I'm confused as to what your problem actually is here. In this part, are you saying you are trying to use this code to hook up to the click event? my code for control button in line button.Click += new EventHandler(this.btn_Click); call button...
8 Apr 2024 by Graeme_Grant
Nostalgic trip... I used Google Search: windows ce 5.0 get list of screens - Google Search[^] and found this: GetSystemMetrics (Windows CE 5.0) | Microsoft Learn[^] Has this paramater: Quote: SM_CMONITORS Number of display monitors on the...
8 Apr 2024 by Graeme_Grant
Set a debug breakpoint on the line: button.Click += new EventHandler(this.btn_Click); and make sure that the line is being hit. If it is, the app will pause on that line.
8 Apr 2024 by Stylus STYLUS
Can't conect button click with buton control My code for button Button btn = (Button)sender; var itemAndPrice = btn.Text; int sno = dataGridView1.Rows.Count + 1; string nazivartikla =...
8 Apr 2024 by OriginalGriff
It's been a long time since I did anything with Win CE, but ... as far as I remember, you can't have multi screens at all - and that would explain why Screen.AllScreens doesn't exist. I suspect you are going to have to rethink your project to an...
8 Apr 2024 by Michi Elsno
I'm trying to develop a Windows CE application in C# in .NET CF2.0 and wanted to know how to get an array of screens. Normally this is done with Screen.AllScreens, but in CF2.0 that is not available. How could I translate Screen.AllScreens to get...
8 Apr 2024 by Rod Kemp
Sounds like you are running into a SPF,DKIM, DMARC authentication issue. SPF is a DNS record that tells the receiving email server if the sending server is a valid sender for the domain in the from field of the email. In your case you have the...
8 Apr 2024 by Aggeliki Asimakopoulou
SqlDataReader doesn't read all columns and their values in C#. My query in Sql Managemnt Studio works perfectly. Where am I wrong there? Any help will be much appreciated. Thank you so much in advanced. sql = "SELECT Invoices.* FROM Invoices...
8 Apr 2024 by Member 11290735
using System; using System.Collections.Generic; using System.Linq; using System.Data; using System.Configuration; using System.Web; using System.Web.Security; using System.Web.UI; using System.Web.UI.WebControls; using...
8 Apr 2024 by Pete O'Hanlon
As you are having a problem with a hosting provider, the best thing for you to do is to get in touch with GoDaddy and talk to their support team. You can find their support here[^].