为什么在VB中表单宽度增加时DataGridView如此奇怪?

时间:2015-12-22 01:32:32

标签: vb.net visual-studio datagridview scrollbar

我的DataGridView设置如下。

struct OddSequence: SequenceType {

    func generate() -> AnyGenerator<Int?> {
        var i = 0
        let generator: AnyGenerator<Int?> = anyGenerator {
            if i >= 4 { return nil }
            i += 1
            return i % 2 != 0 ? Optional(nil) : i
        }

        return generator
    }

}

当整个表单的宽度增加到某个点时,DataGridView的宽度将不再增加。滚动条太奇怪了。截图是: enter image description here

更新

使用下面的代码后,滚动条仍然很奇怪,但更好:

    '
    'DataGridView1
    '
    Me.DataGridView1.AllowDrop = True
    Me.DataGridView1.AllowUserToAddRows = False
    Me.DataGridView1.AllowUserToDeleteRows = False
    Me.DataGridView1.AllowUserToOrderColumns = True
    Me.DataGridView1.AllowUserToResizeColumns = False
    DataGridViewCellStyle1.ForeColor = System.Drawing.Color.Red
    DataGridViewCellStyle1.WrapMode = System.Windows.Forms.DataGridViewTriState.[False]
    Me.DataGridView1.AlternatingRowsDefaultCellStyle = DataGridViewCellStyle1
    Me.DataGridView1.Anchor = CType(((System.Windows.Forms.AnchorStyles.Top Or System.Windows.Forms.AnchorStyles.Left) _
        Or System.Windows.Forms.AnchorStyles.Right), System.Windows.Forms.AnchorStyles)
    Me.DataGridView1.AutoSizeColumnsMode = System.Windows.Forms.DataGridViewAutoSizeColumnsMode.AllCells
    Me.DataGridView1.BorderStyle = System.Windows.Forms.BorderStyle.None
    Me.DataGridView1.ColumnHeadersHeightSizeMode = System.Windows.Forms.DataGridViewColumnHeadersHeightSizeMode.AutoSize
    Me.DataGridView1.GridColor = System.Drawing.SystemColors.Highlight
    Me.DataGridView1.ImeMode = System.Windows.Forms.ImeMode.NoControl
    Me.DataGridView1.Location = New System.Drawing.Point(527, 0)
    Me.DataGridView1.Margin = New System.Windows.Forms.Padding(0, 0, 10, 0)
    Me.DataGridView1.Name = "DataGridView1"
    Me.DataGridView1.RightToLeft = System.Windows.Forms.RightToLeft.No
    Me.DataGridView1.RowTemplate.Height = 28
    Me.DataGridView1.RowTemplate.Resizable = System.Windows.Forms.DataGridViewTriState.[True]
    Me.DataGridView1.Size = New System.Drawing.Size(469, 500)
    Me.DataGridView1.TabIndex = 12

enter image description here

欢迎任何帮助。提前谢谢。

0 个答案:

没有答案