15,893,668 members
Sign in
Sign in
Email
Password
Forgot your password?
Sign in with
home
articles
Browse Topics
>
Latest Articles
Top Articles
Posting/Update Guidelines
Article Help Forum
Submit an article or tip
Import GitHub Project
Import your Blog
quick answers
Q&A
Ask a Question
View Unanswered Questions
View All Questions
View C# questions
View C++ questions
View Javascript questions
View Visual Basic questions
View Python questions
discussions
forums
CodeProject.AI Server
All Message Boards...
Application Lifecycle
>
Running a Business
Sales / Marketing
Collaboration / Beta Testing
Work Issues
Design and Architecture
Artificial Intelligence
ASP.NET
JavaScript
Internet of Things
C / C++ / MFC
>
ATL / WTL / STL
Managed C++/CLI
C#
Free Tools
Objective-C and Swift
Database
Hardware & Devices
>
System Admin
Hosting and Servers
Java
Linux Programming
Python
.NET (Core and Framework)
Android
iOS
Mobile
WPF
Visual Basic
Web Development
Site Bugs / Suggestions
Spam and Abuse Watch
features
features
Competitions
News
The Insider Newsletter
The Daily Build Newsletter
Newsletter archive
Surveys
CodeProject Stuff
community
lounge
Who's Who
Most Valuable Professionals
The Lounge
The CodeProject Blog
Where I Am: Member Photos
The Insider News
The Weird & The Wonderful
help
?
What is 'CodeProject'?
General FAQ
Ask a Question
Bugs and Suggestions
Article Help Forum
About Us
Search within:
Articles
Quick Answers
Messages
Comments by Fydobas (Top 22 by date)
Fydobas
3-Aug-23 6:14am
View
Oh my *expletives*
That was it! I created a test project using .NET Framework, isolated the functionality that had to do with the library... and it worked. All this because Visual Studio 2019 onwards names the .NET Framework WPF template as "WPF *app*" and not "WPF *application*" so I didn't notice it.
*Expletives*
Fydobas
2-Aug-23 5:36am
View
Ugh. You know, I actually hate WinForms and its dated... everything, so much. Yet I'm forced to use it because of stuff like this. Ugh.
Fydobas
2-Aug-23 4:03am
View
To misquote Tenacious D... the peculiar thing is this, my friend: the ERP application the library is sending data to is, almost certainly, made with .NET Core. I'm puzzled as to why the same company would only build a library for .NET Framework... I have contacted them to see if they can provide an alternative in any case
Fydobas
23-May-23 6:32am
View
I have managed to make most of it work using OWIN. Just that for some reason, I cannot get the user name using HttpContext.Current.GetOwinContext().Authentication.User.Identity.Name... it's always empty.
Fydobas
23-May-23 3:59am
View
Oh that makes complete sense. That link you provided, however, is slightly confusing as it seems to be referring to a Web API/MVC project, not Web Forms like my case - and the samples seem incomplete.
Fydobas
22-Jun-22 0:37am
View
Well when you check the boxes on the rows, that does not mean they get selected; in order to get them using SelectedRows, you have to select them programmatically upon the checkbox being checked. Do you do that?
Fydobas
21-Jun-22 4:26am
View
1) This means you should debug the SelectionChanged event to see what the problematic code is and correct it accordingly - do not just comment out the entire code!
2) In the CellEndEdit or CellValidating event, you can do the following:
DateTime effectiveDate;
DateTime expirationDate;
if (DateTime.TryParse(dgvrow.Cells["EffDtDataGridViewTextBoxColumn"].Value,out effectiveDate))
{
expirationDate = effectiveDate.AddYears(1);
dgvrow.Cells["ExpDtDataGridViewTextBoxColumn"].Value = expirationDate;
};
I have taken the grid name and column names from the code you provided above; you may have to correct them if they're not correct.
Fydobas
20-Jun-22 3:48am
View
Try clicking on any other cell after you've checked the checkbox - might be that your grid hasn't exited edit mode yet so it doesn't apply the changes.
Fydobas
17-Jun-22 14:14pm
View
Well after researching it a little bit myself, you can try getting the value using e.FormattedValue.
Here's how the code would look
private void dataGridView1_CellValidating(object sender, DataGridViewCellValidatingEventArgs e)
{
if (!Convert.ToBoolean(dataGridView1.Rows[e.RowIndex].Cells[0].Value)) return;
if(e.ColumnIndex != 0 && dataGridView1.Columns[e.ColumnIndex].Name == "EffDtDataGridViewTextBoxColumn")
{
DateTime DateFormated;
bool isDate = DateTime.TryParseExact(e.FormattedValue, "MM/dd/yyyy", CultureInfo.InvariantCulture, DateTimeStyles.None, out DateFormated);
if (!isDate)
{
MessageBox.Show("value should match MM/DD/yyyy format");
e.Cancel = true; // The important part
return;
}
}
Fydobas
17-Jun-22 4:53am
View
If you want it to check the value only when the checkbox is checked you could add one more condition just to ensure the code behaves the way it should:
private void dataGridView1_CellValidating(object sender, DataGridViewCellValidatingEventArgs e)
{
if (!Convert.ToBoolean(dataGridView1.Rows[e.RowIndex].Cells[0].Value)) return;
if(e.ColumnIndex != 0 && dataGridView1.Columns[e.ColumnIndex].Name == "EffDtDataGridViewTextBoxColumn")
{
string DateValue;
DateTime DateFormated;
DateValue = dataGridView1.Rows[e.RowIndex].Cells[e.ColumnIndex].Value.ToString();
bool isDate = DateTime.TryParseExact(DateValue, "MM/dd/yyyy", CultureInfo.InvariantCulture, DateTimeStyles.None, out DateFormated);
if (!isDate)
{
MessageBox.Show("value should match MM/DD/yyyy format");
e.Cancel = true; // The important part
return;
}
}
The if (!Convert.ToBoolean(dataGridView1.Rows[e.RowIndex].Cells[0].Value)) return; tells it to ignore the event if the checkbox value converts to false. Other than that, I think you're set - except you again forgot to correct the date format, "dd" should be in lowercase - I have corrected it in my example
Fydobas
17-Jun-22 2:25am
View
I get it it wasn't the date format?
Instead of:
DateValue = dataGridView1.CurrentRow.Cells["EffDtDataGridViewTextBoxColumn"].Value.ToString();
you would have:
DateValue = dataGridView1.Rows[e.RowIndex].Cells[e.ColumnIndex].Value.ToString();
Please also try putting the TryParse in a variable as I showed you above, it will make it easier to test
(quoting my comment above:
if (!DateTime.TryParseExact(DateValue, "MM/DD/yyyy", CultureInfo.InvariantCulture, DateTimeStyles.None, out DateFormated))
{
MessageBox.Show("value should match MM/DD/yyyy format");
e.Cancel = true; // The important part
return;
}
would become
bool isDate = DateTime.TryParseExact(DateValue, "MM/dd/yyyy", CultureInfo.InvariantCulture, DateTimeStyles.None, out DateFormated);
if (!isDate)
{
MessageBox.Show("value should match MM/DD/yyyy format");
e.Cancel = true; // The important part
return;
}
)
Fydobas
16-Jun-22 5:31am
View
Reading your code, in the face of it there doesn't seem to be any error - you might possibly have an incorrect date format, however. "MM/DD/yyyy" should be "MM/dd/yyyy" - so "dd" shouldn't be in capitals.
In case that doesn't do the trick, I would suggest the following:
- Add a breakpoint in the if clause to check the DateValue - it's possible it's not being read correctly.
- Try getting the row and cell via their indexes instead of the CurrentRow function and the name of the column, in case it does not read the correct value
- You can also try - that would also make your code more readable and testable - putting the TryParseExact output in a boolean variable and checking against the variable:
if (!DateTime.TryParseExact(DateValue, "MM/DD/yyyy", CultureInfo.InvariantCulture, DateTimeStyles.None, out DateFormated))
{
MessageBox.Show("value should match MM/DD/yyyy format");
e.Cancel = true; // The important part
return;
}
would become
bool isDate = DateTime.TryParseExact(DateValue, "MM/DD/yyyy", CultureInfo.InvariantCulture, DateTimeStyles.None, out DateFormated);
if (!isDate)
{
MessageBox.Show("value should match MM/DD/yyyy format");
e.Cancel = true; // The important part
return;
}
This way you can test the TryParseExact function more easily and see what part it doesn't parse correctly.
Fydobas
16-Jun-22 3:23am
View
Hopefully I explained them well enough - I'm not good at teaching of any kind. If you have any further questions feel free to ask.
Fydobas
16-Jun-22 2:55am
View
If you simply want to exclude the CheckBox, it's actually quite a simple fix:
private void dataGridView1_CellBeginEdit(object sender, DataGridViewCellCancelEventArgs e)
{
if (e.ColumnIndex == 0) return;
cellValue = dataGridView1.Rows[e.RowIndex].Cells[e.ColumnIndex].Value;
}
private void dataGridView1_CellEndEdit(object sender, DataGridViewCellEventArgs e)
{
if (e.ColumnIndex == 0) return;
if (cellValue != dataGridView1.Rows[e.RowIndex].Cells[e.ColumnIndex].Value)
{
cellUpdateCounter += 1;
}
}
I have added a simple "if (e.ColumnIndex == 0) return;" statement to both functions, which tells the code to simply skip the functions if the edited column is the first column - as you have stated your CheckBox is the first column in your grid. Change 0 to the index of the CheckBox column in case it's not the first.
Also I think you have a mistake in your code:
Look at this part:
if (cellUpdateCounter != 0)
{
Update();
}
MessageBox.Show("No records are updated");
This would, if I'm reading it right, always show the message regardless of whether any records have been updated or not. I think you need to invert the statement as follows
if (cellUpdateCounter == 0)
{
MessageBox.Show("No records are updated");
return; //skip any following code
}
Update();
Fydobas
16-Jun-22 0:57am
View
Your methods seem a little unconventional - normally, as is standard practice, you should be updating each cell in the CellValueChanged event, not updating them all at once after editing - so you needn't be worried about what cells have changed etc.
If you have to do it the way you're doing it, you can do the following:
Add the following two variables in the class level
private int cellUpdateCounter = 0;
private object cellValue;
Add the following logic for capturing the cell value and checking it against the edited one
private void dataGridView1_CellBeginEdit(object sender, DataGridViewCellCancelEventArgs e)
{
cellValue = dataGridView1.Rows[e.RowIndex].Cells[e.ColumnIndex].Value;
}
private void dataGridView1_CellEndEdit(object sender, DataGridViewCellEventArgs e)
{
if (cellValue != dataGridView1.Rows[e.RowIndex].Cells[e.ColumnIndex].Value)
{
cellUpdateCounter += 1;
}
}
Then in your click method...
private void btnUpdate_Click(object sender, EventArgs e)
{
if (cellUpdateCounter == 0) {
MessageBox.Instance.ShowMessageBox("No records are updated");
return;}
// do stuff
}
Again, this code has not been tested - but it should work as expected
Fydobas
15-Jun-22 3:00am
View
Oh that part was not clarified on your question - either that or I misread. The way your question was worded, it seemed as if the "No records are updated" message was being fired even though it shouldn't.
That part is a little more complicated. Ideally, you would have a CellValueChanged event, in which event you would iterate a class level (rather than function level) counter variable just like the example I showed you above - and, in addition, you would have to check if the new cell value is, each time, not equal to the old value; and you will have to do that according to your own app structure, I can't show you here without knowing how your DataGridView is populated and how you handle your events.
After you do that, on the "click" function, you would have to check the second counter you added in the previous step - if that's equal to 0, you show your message.
Fydobas
29-Jul-21 6:24am
View
I used the ciphers that were mentioned in the Qualys SSL Server Test tool.
Namely, the three ciphers below that Qualys mentioned were supported by the server were completely missing from the cipher suite list when I checked using the IISCrypto tool (using TLS 1.2, as the .NET Framework I am using does not support TLS 1.3).
TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256
TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384
TLS_ECDHE_RSA_WITH_CHACHA20_POLY1305_SHA256
I added them in that specific order as the first three suites using IISCrypto but it did not seem to work. They're not on the list you linked above, but none of those mentioned in the Qualys test are.
Fydobas
29-Jul-21 3:54am
View
As mentioned above, I ran the same test you mention on the comment below for the API I am trying to access and found out the cipher suites the API's server was supporting were not even included on the list of cipher suites available on the client's server. I tried adding the options mentioned in the test but that did not work - I still got the same error message.
As for the .NET framework, I am using 4.7.2 - I also tried downgrading down to 4.5.0 but it did not help. It is mentioned in the article that in that case, I should not change anything in my code, yet naturally that was not the answer - so I tried the other solutions as well. Neither setting the AppContext switch nor setting the registry key seemed to solve the issue, however.
After communicating with the API provider, they suggested the "newer cryptographic protocols do not work with Windows Server 2012 R2 and the client needs to update their OS". However, I strongly believe that there should be a solution to the issue - if there was an issue with the OS, the Insomnia REST client would return a similar error, not work correctly.
Fydobas
21-Jul-21 2:53am
View
Appears that none of these suggestions worked - I am still facing the same issue ("The request was aborted: Could not create SSL/TLS secure channel"). Reminder: the server is running Windows Server 2012 R2. Could it be an operating system issue? Albeit keep in mind third-party clients (Insomnia REST, Postman) work fine. In addition, the same application works perfectly in Windows 10 and newer Windows Server.
Fydobas
26-Apr-17 1:31am
View
So,problem solved (or it seems so after two days of extensive testing):
I was connecting once - that was,when a user opened the website - and then used the same connection for everything. So,SQL server treated every command as if it was being sent from one sole connection; which,naturally,caused a load of deadlocks. Issue was solved by closing and re-opening the connection each time I sent a command to SQL server: seems like it needs to be this way!
Fydobas
24-Apr-17 5:09am
View
So I found the issue... It has to do with SQL Server running two commands simultaenously (e.g. one user logging in and another logging out,beware that we are talking about the exact same millisecond).
Logging in and out is achieved by two SQL procedures,each of whom has its own transaction on,which (the transaction) has COMMIT and ROLL BACK statements. (No,I do not use Forms Authentication)
Is there a specific solution for this issue? Because it has never happened to me before...
Fydobas
18-Apr-17 6:46am
View
Thank you very much,I will try to see if any of these help and will inform you afterwards
Show More