Ask your PowerShell-related questions, including questions on cmdlet development!
Forum rules Do not post any licensing information in this forum.
Any code longer than three lines should be added as code using the 'Select Code' dropdown menu or attached as a file.
This topic is 5 years and 11 months old and has exceeded the time allowed for comments. Please begin a new topic or use the search feature to find a similar but newer topic.
I am trying to combine the first two cells in a row. One is the Firstname and the other is Lastname. I want to check Active Directory and make sure that combination doesn't exists as the CN. If it does, I want to use the CellPaintingEventHandler to turn the backcolor to red. I can check one cell but combing the two and checking i am having difficulty with. I have two other columns that i am checking and they work just fine. Here is what i currently have under the CellPaintingEventHandler.
Don't you think it would be much easier to create the code to match the FirstName+UserName outside the DataGridView? This way you can build the result PSObject to Display the ones with the issues on a separate code, like a custom function.
Ok, so my overall goal is to have the end user have the cell marked red for issues on the spreadsheet. The code i posted are for the username and password columns. I am able to wrap my head around just checking one column for an issue but the problem i am having is combining two of them and marking the cells red if there is an issue. I could create an outside function or just a variable that matches Firstname + Lastname but how would i mark the cells red to notify of the issue. I am just having an issue on how would i go about adding that in the System.Windows.Forms.DataGridViewCellPaintingEventHandler.
I was trying to give the hint of creating a psobject property to identify the ones with issues.
Then, use that object property object value to paint the cell.
Which part are you saying no to? So, should i collect all of the rows in the Datagrid and run a foreach loop for each row and pull out the first two cells per row? So in turn that variable will hold the Firstname and Lastname. Then take that variable and check Active Directory?
falconcurt wrote: ↑Thu May 17, 2018 7:11 am
Which part are you saying no to? So, should i collect all of the rows in the Datagrid and run a foreach loop for each row and pull out the first two cells per row? So in turn that variable will hold the Firstname and Lastname. Then take that variable and check Active Directory?
Yes. Paint is not useful for this kind of thing. Paint is at the cell level and you want to address multiple cells. I is easiest to prep the data first.
That explains why I had issues trying to place it in the Paint Event. I was able to get what i was looking for by using the following code. Maybe this will help others.
This topic is 5 years and 11 months old and has exceeded the time allowed for comments. Please begin a new topic or use the search feature to find a similar but newer topic.