DataGridView add header cell number

Ask questions about creating Graphical User Interfaces (GUI) in PowerShell and using WinForms controls.
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 6 years and 10 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.
Locked
User avatar
ramses147
Posts: 110
Last visit: Tue Dec 05, 2023 7:11 am
Been upvoted: 1 time

Re: DataGridView add header cell number

Post by ramses147 »

With that code no errors, but the numbers are not visible
Attachments
a.jpg
a.jpg (23.54 KiB) Viewed 2683 times
jvierra
Posts: 15439
Last visit: Tue Nov 21, 2023 6:37 pm
Answers: 30
Has voted: 4 times
Been upvoted: 33 times

Re: DataGridView add header cell number

Post by jvierra »

You still have to add that to the event.
User avatar
ramses147
Posts: 110
Last visit: Tue Dec 05, 2023 7:11 am
Been upvoted: 1 time

Re: DataGridView add header cell number

Post by ramses147 »

is this the event ?
  1. $DataGridView.add_RowPostPaint()
User avatar
ramses147
Posts: 110
Last visit: Tue Dec 05, 2023 7:11 am
Been upvoted: 1 time

Re: DataGridView add header cell number

Post by ramses147 »

i added it,
But there are continuous refresh flashes and the buttons are gone as in the picture
Attachments
b.jpg
b.jpg (54.07 KiB) Viewed 2679 times
jvierra
Posts: 15439
Last visit: Tue Nov 21, 2023 6:37 pm
Answers: 30
Has voted: 4 times
Been upvoted: 33 times

Re: DataGridView add header cell number

Post by jvierra »

You cannot add rows to the grid. Rows have to be added to the data table.
User avatar
ramses147
Posts: 110
Last visit: Tue Dec 05, 2023 7:11 am
Been upvoted: 1 time

Re: DataGridView add header cell number

Post by ramses147 »

Like this ?
  1. $dataGridView_RowPostPaint = [System.Windows.Forms.DataGridViewRowPostPaintEventHandler]{
  2.     $dataGridView.Rows[$_.RowIndex].HeaderCell.Value = $_.RowIndex.ToString()
  3. }
  4. $dt.add_RowPostPaint($dataGridView_RowPostPaint)
  5. $dataGridView.DataSource = $dt
User avatar
ramses147
Posts: 110
Last visit: Tue Dec 05, 2023 7:11 am
Been upvoted: 1 time

Re: DataGridView add header cell number

Post by ramses147 »

Where am I wrong? I do not need to add rows to GridView but to add them to the DataTable I do not have to do as I have written?
jvierra
Posts: 15439
Last visit: Tue Nov 21, 2023 6:37 pm
Answers: 30
Has voted: 4 times
Been upvoted: 33 times

Re: DataGridView add header cell number

Post by jvierra »

Sorry. I can not understand what you are doing or why you are having issues.

DO what I asked and download the PSS trial. Use it to learn how to build a form. It will get you up to speed very quickly.
User avatar
ramses147
Posts: 110
Last visit: Tue Dec 05, 2023 7:11 am
Been upvoted: 1 time

Re: DataGridView add header cell number

Post by ramses147 »

I downloaded pss, i try on it to catch a right code or a debug to this specific problem.

you said that i can't add datagridview, so i suppose that the problem is on this string:
  1. $dataGridView.add_RowPostPaint($dataGridView_RowPostPaint)
If I do not have to put the rows in the DataGridView I have to include them in the DataTable, I just asked you how to put them in order to avoid the problem of continuous refresh of the rows numbers when I open the form.
Last edited by ramses147 on Fri May 26, 2017 4:18 pm, edited 1 time in total.
User avatar
ramses147
Posts: 110
Last visit: Tue Dec 05, 2023 7:11 am
Been upvoted: 1 time

Re: DataGridView add header cell number

Post by ramses147 »

You can show on the attachment, it's very strange.
as the form refresh anytime
Attachments
form video screen.zip
(485.38 KiB) Downloaded 115 times
This topic is 6 years and 10 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.
Locked