I've populated an unbound grid, and even put a delay in to make sure it's populated, but the auto resize after that does not work - i.e. if I click on the column boundary between columns 1 & 2, column 1 obediently shrinks down - but this code is not doing the same thing:
The code to populate and resize:
Private Sub Populate_Products_Grids() Try Grd_Prods.DataSource = Nothing Catch ex As Exception End Try Me.Cursor = Cursors.WaitCursor UseWaitCursor = True Application.DoEvents() Threading.Thread.Sleep(100) 'WAITING FOR THE CODE TO FINISH ConnectString = "Server = xx.xxxx.xx.xx; Log File=cprovider.log;Port=1972; Namespace=" & CompName & "; Password = TEST; User ID = TEST;" Try cnCache = New InterSystems.Data.CacheClient.CacheConnection(ConnectString) cnCache.Open() dsCache = New DataSet() daCache = New InterSystems.Data.CacheClient.CacheDataAdapter SQLstmt = "SELECT Convert(bit,0) as Choose, Product, Description FROM MVFILE.PRODUCTS" daCache.SelectCommand = New InterSystems.Data.CacheClient.CacheCommand(SQLstmt, cnCache, txCache) daCache.Fill(dsCache, "Sample_Person") dtCache = dsCache.Tables("Sample_Person") Grd_Prods.DataSource = dtCache Catch eLoad As Exception MessageBox.Show("An error has occurred: " + eLoad.Message) Application.Exit() End Try Threading.Thread.Sleep(100) 'WAITING FOR THE CODE TO FINISH Grd_Prods.DisplayLayout.Bands(0).Columns(1).PerformAutoResize(PerformAutoSizeType.AllRowsInBand) Grd_Prods.DisplayLayout.Bands(0).Columns(2).PerformAutoResize(PerformAutoSizeType.AllRowsInBand) UseWaitCursor = False Me.Cursor = Cursors.Default Application.DoEvents() Threading.Thread.Sleep(100) 'WAITING FOR THE CODE TO FINISH End Sub
In addition, this grid is read-only, which is what I want, sort of, but I'm not sure how this is accomplished globally (I used a preset read-only style), nor how to override it for a column. I have a checkbox column (created within the SQL statement, as you can see above), and I'm trying to let them check/uncheck boxes in that column while prohibiting any other kinds of editing, but it's not working:
My Initialize:
Private Sub Grd_Prods_InitializeLayout(sender As Object, e As InitializeLayoutEventArgs) Handles Grd_Prods.InitializeLayoute.Layout.Bands(0).Columns(0).CellActivation = Activation.AllowEdite.Layout.Bands(0).Columns(0).CellClickAction = CellClickAction.EditEnd Sub
Yes, loaded at design time. I've already uploaded a sample based on a case that was created from another forum entry. I've specified both the problem from that forum post and this one there (they seem like they may be related), so I think I'll leave it with that case for now.
Thanks.
Hi Samuel,
Samuel Claiborne said:Actually, my code's executing afterwards, no?
Um... I'm not sure. How would I know when you are loading your preset? I don't see that anywhere in your code. Are you saying you loaded the preset at design-time? If so, then yes, I guess you are loading the preset before this code gets called. So that brings us back to square one, then. If that's the case, then I am out of ideas.
At this point, unless you can reproduce the problem in a small sample project and post it here, I'm not sure what else I can do to assist you.
OK. I understand that. But humor my abject stupidity: I selected the preset, but I didn't code a 'load' of it, though I am aware that it is indeed loaded. So, 'where and when' is it loaded, and how do I make sure that my code executes afterwards?
Actually, my code's executing afterwards, no? True, I executed my code first in initializelayout, which might be before, but now I am executing it after I populate the grid, yet it is still have no affect.
Thanks,.
The key here is to make sure that the PerformAutoSize is called AFTER you load the layout or the preset. If you call it before, then loading the layout will essentially blow away any settings you applied in favor of the layout/preset.
Ooops. No, I'm loading presets, not layouts!