在我的应用程序中,我有一个DataGridView从一个选项卡控件移动到另一个选项卡控件。更改控件父级删除内容
我正在通过更改其父项来完成此操作。这在第一次从原始选项卡控件移动到新选项时没有问题,但是在将父项更改回原始时,DataGridView显示(所有列都可见),但视图中没有数据。
我已经尝试将数据重新加载到DataGridView,并刷新/使该控件失效,使其重绘,但它仍然显示为空。但是,当控件返回到辅助父级时,数据会回来。
我也为另一个DataGridView使用这个确切的代码,它工作没有任何问题。
任何想法将不胜感激,并在此先感谢。
从原始到二次
gvwRFIs.Parent = tabProcessingRFI; //Working
gvwConsentInfoMemos.Parent = tabProcessingMemos; //Working
从继发于原始
gvwRFIs.Parent = tabConsentInfoRFI; //Empty Data
gvwConsentInfoMemos.Parent = tabConsentInfoMemos; //Working
RFI的DataGridView设计代码
//
// gvwRFIs
//
this.gvwRFIs.AllowUserToAddRows = false;
this.gvwRFIs.AllowUserToDeleteRows = false;
this.gvwRFIs.AllowUserToResizeRows = false;
this.gvwRFIs.AutoSizeRowsMode = System.Windows.Forms.DataGridViewAutoSizeRowsMode.AllCellsExceptHeaders;
this.gvwRFIs.BackgroundColor = System.Drawing.Color.White;
this.gvwRFIs.ColumnHeadersHeightSizeMode = System.Windows.Forms.DataGridViewColumnHeadersHeightSizeMode.AutoSize;
this.gvwRFIs.Columns.AddRange(new System.Windows.Forms.DataGridViewColumn[] {
this.gvwID,
this.gvwType,
this.gvwSeq,
this.gvwCreated,
this.gvwProcessor,
this.gvwLetter,
this.gvwResponded,
this.gvwS,
this.gvwDetails});
this.gvwRFIs.Dock = System.Windows.Forms.DockStyle.Fill;
this.gvwRFIs.Location = new System.Drawing.Point(3, 3);
this.gvwRFIs.MultiSelect = false;
this.gvwRFIs.Name = "gvwRFIs";
this.gvwRFIs.ReadOnly = true;
this.gvwRFIs.RowHeadersVisible = false;
this.gvwRFIs.RowHeadersWidth = 4;
this.gvwRFIs.SelectionMode = System.Windows.Forms.DataGridViewSelectionMode.FullRowSelect;
this.gvwRFIs.Size = new System.Drawing.Size(1078, 422);
this.gvwRFIs.TabIndex = 4;
this.gvwRFIs.DoubleClick += new System.EventHandler(this.gvwRFIs_DoubleClick);
同意选项卡控制设计代码
//
// tabConsentInfoRFI
//
this.tabConsentInfoRFI.Controls.Add(this.gvwRFIs);
this.tabConsentInfoRFI.Controls.Add(this.lvwConsentInfoRFI);
this.tabConsentInfoRFI.Location = new System.Drawing.Point(4, 32);
this.tabConsentInfoRFI.Name = "tabConsentInfoRFI";
this.tabConsentInfoRFI.Padding = new System.Windows.Forms.Padding(3);
this.tabConsentInfoRFI.Size = new System.Drawing.Size(1084, 428);
this.tabConsentInfoRFI.TabIndex = 4;
this.tabConsentInfoRFI.Text = "RFI\'s";
this.tabConsentInfoRFI.UseVisualStyleBackColor = true;
处理标签控件设计准则
//
// tabProcessingRFI
//
this.tabProcessingRFI.Location = new System.Drawing.Point(4, 36);
this.tabProcessingRFI.Name = "tabProcessingRFI";
this.tabProcessingRFI.Padding = new System.Windows.Forms.Padding(3);
this.tabProcessingRFI.Size = new System.Drawing.Size(868, 465);
this.tabProcessingRFI.TabIndex = 1;
this.tabProcessingRFI.Text = "RFI";
this.tabProcessingRFI.UseVisualStyleBackColor = true;
如果代码在另一个网格上工作,那么问题不会在发布的代码。尝试查看可能导致问题的任何事件处理程序。 – LarsTech
这个或其他DataGridView处理的唯一事件是doubleclick事件。我将发布上面的两个DataGridView的设计器代码。所有双击事件都会打开另一个窗体。 – Seige