0

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

我将属性 ScrollBars 设置为 Vertical。

  • 添加结果后,该栏会出现,并且看起来正在按预期工作。
  • 如果我在鼠标上滚动它会滚动
  • 但是,如果我尝试与酒吧互动,它什么也不做。

The only thing I am doing that is a bit odd is setting select to entire row as when one is selected it causes a popup.

另请注意,这是使用 C# 和 Net-office 的 Outlook 插件,但可能没有区别。

有任何想法吗?

在此处输入图像描述

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

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

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);

4

0 回答 0