Setting some columns read only in UltraGrid

I need to set all the columns into an ultra grid to read only except for the first column in position 0.
To do this, I was attempting to use a foreach loop over the column index but I’m not quite there.
image
I get this error:

I’d appreciate a nudge in the right direction, thanks!

It’s a col, not a row, there is not indexing. You can do it at the table level like this

//update props
	foreach(DataColumn c in edvUD107A.dataView.Table.Columns)
		{
			if (!c.Caption.ToUpper().Contains("SHIPPING") && !c.Caption.ToUpper().Contains("STORAGE") &&!c.Caption.ToUpper().Contains("MTL") &&!c.Caption.ToUpper().Contains("PROCESSING") )
				{
					c.ExtendedProperties["ReadOnly"] = true;
				}
		}

or via grid

foreach(UltraGridColumn col in band.Columns)
		{

				if (!col.Header.Caption.ToUpper().Contains("SHIPPING") && !col.Header.Caption.ToUpper().Contains("STORAGE") &&!col.Header.Caption.ToUpper().Contains("MTL") &&!col.Header.Caption.ToUpper().Contains("PROCESSING") )
				{			
					col.CellActivation = Activation.Disabled;
		
				} 		
		}
4 Likes

Thanks Chris!

  	/*Make all columns except for Allocate column read only*/
  	
  	foreach(var col in grdAllocations.DisplayLayout.Bands[0].Columns)
  	{
  		if(!col.Header.Caption.Contains("Allocate"))
  		{
  			col.CellActivation = Activation.Disabled;	
  		}			
  	}
1 Like

@Chris_Conn I was wondering if there is a way to get this to look like it does when I use the override band method
The Top grid shows when I use the CellActivation Property.
The Bottom grid shows when I use the Bands.Override.AllowUpdate property.

I prefer the look when the band is overridden but it doesn’t seem to be visually the same, although they both accomplish the “read only” goal

Got it; I used the data column ordinal property along side the data column read only property to accomplish.Kinda sloppy but it works!

1 Like