Notifications
Clear all

[Closed] Hide Column in DataGridView

I want made script for object properties with DataGridView
The problem that I want to hide some columns depend on current render. So when the user choose not Vray render the columns that correspond for Vray properties hides.

1.Add callback

callbacks.addScript #postRendererChange "HideVrayColumns()" id:#RendChange
  1. Function for hidden
 fn HideVrayColumns = 
		(  rencur =  renderers.current as String
			
			if (matchPattern  rencur pattern:"*V_ray*" ) == true then 
			(   -- HERE THE PROBLEM PART
				rltMain.dnctrlDataGridView.Columns["VrayMat"].Visible = true) 
                                                   else (rltMain.dnctrlDataGridView.Columns["VrayMat"].Visible = false)
			
			
			
		)	

The columns property seems read only.Is there are a way to do this ?
.Columns : <System.Windows.Forms.DataGridViewColumnCollection>, read-only

7 Replies
1 Reply
 lo1
(@lo1)
Joined: 1 year ago

Posts: 0

What this means is that you can not directly set the property DataGridViewColumnCollection of DataGridView.
It does not mean that all sub-properties (for example, properties of individual columns of the columnCollection) are read only.

i don’t think that there is any callback on current renderer changing.

2 Replies
 lo1
(@lo1)
Joined: 1 year ago

Posts: 0

Of course there is, #preRendererChange and #postRendererChange

(@denist)
Joined: 1 year ago

Posts: 0

oh… i’ve not awoke yet.

 lo1

use

rltMain.dnctrlDataGridView.Columns.[B]item[/B]["VrayMat"].visible

That is the syntax to access members of dotnet collections.

 lo1

Sorry for so many posts in a row

I think a simpler check for this is

classof renderers.current != vray

lo
Thanks for help!