C#System.Windows.Forms.DataGridView垂直滚动是可见的但不能使用

时间:2015-04-16 03:32:29

标签: c# winforms datagridview scrollbar netoffice

我正在使用DataGridView存储一些搜索结果,但似乎无法让网格上的滚动条生效。

我将ScrollBars属性设置为Vertical。

  • 添加结果时,条形图显示并且看起来按预期工作。
  • 如果我滚动鼠标滚动
  • 但如果我尝试与酒吧互动,它什么都不做。

我唯一要做的就是有点奇怪的是将select设置为整行,因为当选择一个时它会导致弹出。

另请注意,这是使用C#和Net-office的Outlook添加,但这可能没什么区别。

有什么想法吗?

enter image description here

如您所见,填充的网格显示您无法使用的工具栏

将行添加到数据网格的代码



if (mailItem.Parent is Outlook.MAPIFolder)
{
  ParentFolder = mailItem.Parent as Outlook.MAPIFolder;
  ResultGrd.Rows.Add(mailItem.EntryID, ParentFolder.FolderPath, mailItem.SenderName, mailItem.Subject, mailItem.SentOn);
}




生成有关数据网格的代码,以便您可以查看所有设置:



// 
// ResultGrd
// 
this.ResultGrd.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom) 
| System.Windows.Forms.AnchorStyles.Left) 
| System.Windows.Forms.AnchorStyles.Right)));
this.ResultGrd.AutoSizeColumnsMode = System.Windows.Forms.DataGridViewAutoSizeColumnsMode.AllCells;
dataGridViewCellStyle1.Alignment = System.Windows.Forms.DataGridViewContentAlignment.MiddleLeft;
dataGridViewCellStyle1.BackColor = System.Drawing.SystemColors.Control;
dataGridViewCellStyle1.Font = new System.Drawing.Font("Microsoft Sans Serif", 9F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
dataGridViewCellStyle1.ForeColor = System.Drawing.SystemColors.WindowText;
dataGridViewCellStyle1.SelectionBackColor = System.Drawing.SystemColors.Highlight;
dataGridViewCellStyle1.SelectionForeColor = System.Drawing.SystemColors.HighlightText;
dataGridViewCellStyle1.WrapMode = System.Windows.Forms.DataGridViewTriState.False;
this.ResultGrd.ColumnHeadersDefaultCellStyle = dataGridViewCellStyle1;
this.ResultGrd.ColumnHeadersHeightSizeMode = System.Windows.Forms.DataGridViewColumnHeadersHeightSizeMode.AutoSize;
this.ResultGrd.Columns.AddRange(new System.Windows.Forms.DataGridViewColumn[] {
this.ItemEntityID,
this.FolderH,
this.SenderH,
this.SubjectH,
this.DateH});
this.ResultGrd.Location = new System.Drawing.Point(13, 151);
this.ResultGrd.Name = "ResultGrd";
this.ResultGrd.ReadOnly = true;
this.ResultGrd.ScrollBars = System.Windows.Forms.ScrollBars.Vertical;
this.ResultGrd.SelectionMode = System.Windows.Forms.DataGridViewSelectionMode.FullRowSelect;
this.ResultGrd.Size = new System.Drawing.Size(996, 381);
this.ResultGrd.TabIndex = 4;
this.ResultGrd.CellContentClick += new System.Windows.Forms.DataGridViewCellEventHandler(this.dataGridView1_CellContentClick);




0 个答案:

没有答案