gpt4 book ai didi

vb.net - 无法从 datagridview 复制粘贴

转载 作者:行者123 更新时间:2023-12-04 21:39:00 26 4
gpt4 key购买 nike

我有一个简单的空白窗体作为测试项目
和一个数据 GridView
以及填充数据 GridView 的查询

在这个测试项目中。我可以突出显示所有的列和行

单击 CTRL + C

打开excel

然后点击 ctrl + V

数据就在那里。

但是在我从公司某人那里继承的一个程序上
我有一个类似的数据 GridView 。但我不能复制粘贴

我怎样才能确定这里有什么区别?
我检查了测试项目和我继承的程序的数据 GridView 属性。两者具有相同的以下内容:
1.只读=假
2.copyclipboardmode = EnableWithAutoHeaderText

还有什么可以阻止我复制粘贴这个值?

在继承的程序中,复制粘贴的唯一方法是双击单元格并复制,但是。这限制了我一次复制一个单元格,而不是多个单元格

请指教?

谢谢你

这是我的测试项目中的代码片段

Private Sub Form1_Load(sender As Object, e As EventArgs) Handles Me.Load
DataGridView1.Rows.Add(New String() {"TEST", "TEST2", "TEST3"})
DataGridView1.Rows.Add(New String() {"TEST", "TEST2", "TEST3"})
DataGridView1.Rows.Add(New String() {"TEST", "TEST2", "TEST3"})
DataGridView1.Rows.Add(New String() {"TEST", "TEST2", "TEST3"})
DataGridView1.Rows.Add(New String() {"TEST", "TEST2", "TEST3"})
DataGridView1.Rows.Add(New String() {"TEST", "TEST2", "TEST3"})
DataGridView1.Rows.Add(New String() {"TEST", "TEST2", "TEST3"})
End Sub

这是 QuickDanger 要求的 frmForm.Designer.vb
    <Global.Microsoft.VisualBasic.CompilerServices.DesignerGenerated()> _
Partial Class frmForm
Inherits System.Windows.Forms.Form

'Form overrides dispose to clean up the component list.
<System.Diagnostics.DebuggerNonUserCode()> _
Protected Overrides Sub Dispose(ByVal disposing As Boolean)
Try
If disposing AndAlso components IsNot Nothing Then
components.Dispose()
End If
Finally
MyBase.Dispose(disposing)
End Try
End Sub

'Required by the Windows Form Designer
Private components As System.ComponentModel.IContainer

'NOTE: The following procedure is required by the Windows Form Designer
'It can be modified using the Windows Form Designer.
'Do not modify it using the code editor.
<System.Diagnostics.DebuggerStepThrough()> _
Private Sub InitializeComponent()
Me.dgvSpecials = New System.Windows.Forms.DataGridView()
Me.btnCreate = New System.Windows.Forms.Button()
Me.PartCode = New System.Windows.Forms.DataGridViewTextBoxColumn()
Me.PDF = New System.Windows.Forms.DataGridViewTextBoxColumn()
Me.SLDDRW = New System.Windows.Forms.DataGridViewTextBoxColumn()
Me.SLDPRT = New System.Windows.Forms.DataGridViewTextBoxColumn()
Me.BasePartCode = New System.Windows.Forms.DataGridViewTextBoxColumn()
Me.TEMPLATESLDDRW = New System.Windows.Forms.DataGridViewTextBoxColumn()
Me.TEMPLATESLDPRT = New System.Windows.Forms.DataGridViewTextBoxColumn()
Me.TEMPLATEDRWFILE = New System.Windows.Forms.DataGridViewTextBoxColumn()
Me.TEMPLATEPRTFILE = New System.Windows.Forms.DataGridViewTextBoxColumn()
Me.MakeSpecial = New System.Windows.Forms.DataGridViewCheckBoxColumn()
CType(Me.dgvSpecials, System.ComponentModel.ISupportInitialize).BeginInit()
Me.SuspendLayout()
'
'dgvSpecials
'
Me.dgvSpecials.ColumnHeadersHeightSizeMode = System.Windows.Forms.DataGridViewColumnHeadersHeightSizeMode.AutoSize
Me.dgvSpecials.Columns.AddRange(New System.Windows.Forms.DataGridViewColumn() {Me.PartCode, Me.PDF, Me.SLDDRW, Me.SLDPRT, Me.BasePartCode, Me.TEMPLATESLDDRW, Me.TEMPLATESLDPRT, Me.TEMPLATEDRWFILE, Me.TEMPLATEPRTFILE, Me.MakeSpecial})
Me.dgvSpecials.Dock = System.Windows.Forms.DockStyle.Fill
Me.dgvSpecials.Location = New System.Drawing.Point(0, 0)
Me.dgvSpecials.Name = "dgvSpecials"
Me.dgvSpecials.Size = New System.Drawing.Size(917, 246)
Me.dgvSpecials.TabIndex = 0
'
'btnCreate
'
Me.btnCreate.Dock = System.Windows.Forms.DockStyle.Bottom
Me.btnCreate.Location = New System.Drawing.Point(0, 246)
Me.btnCreate.Name = "btnCreate"
Me.btnCreate.Size = New System.Drawing.Size(917, 30)
Me.btnCreate.TabIndex = 1
Me.btnCreate.Text = "Create"
Me.btnCreate.UseVisualStyleBackColor = True
'
'PartCode
'
Me.PartCode.HeaderText = "Part Code"
Me.PartCode.Name = "PartCode"
Me.PartCode.ReadOnly = True
Me.PartCode.Width = 200
'
'PDF
'
Me.PDF.HeaderText = "PDF"
Me.PDF.Name = "PDF"
Me.PDF.ReadOnly = True
'
'SLDDRW
'
Me.SLDDRW.HeaderText = "SLDDRW"
Me.SLDDRW.Name = "SLDDRW"
Me.SLDDRW.ReadOnly = True
'
'SLDPRT
'
Me.SLDPRT.HeaderText = "SLDPRT"
Me.SLDPRT.Name = "SLDPRT"
Me.SLDPRT.ReadOnly = True
'
'BasePartCode
'
Me.BasePartCode.HeaderText = "Base Part"
Me.BasePartCode.Name = "BasePartCode"
Me.BasePartCode.ReadOnly = True
'
'TEMPLATESLDDRW
'
Me.TEMPLATESLDDRW.HeaderText = "DRW Template"
Me.TEMPLATESLDDRW.Name = "TEMPLATESLDDRW"
Me.TEMPLATESLDDRW.ReadOnly = True
'
'TEMPLATESLDPRT
'
Me.TEMPLATESLDPRT.HeaderText = "PRT Template"
Me.TEMPLATESLDPRT.Name = "TEMPLATESLDPRT"
'
'TEMPLATEDRWFILE
'
Me.TEMPLATEDRWFILE.HeaderText = "Column1"
Me.TEMPLATEDRWFILE.Name = "TEMPLATEDRWFILE"
Me.TEMPLATEDRWFILE.ReadOnly = True
Me.TEMPLATEDRWFILE.Visible = False
'
'TEMPLATEPRTFILE
'
Me.TEMPLATEPRTFILE.HeaderText = "Column1"
Me.TEMPLATEPRTFILE.Name = "TEMPLATEPRTFILE"
Me.TEMPLATEPRTFILE.ReadOnly = True
Me.TEMPLATEPRTFILE.Visible = False
'
'MakeSpecial
'
Me.MakeSpecial.HeaderText = "MakeSpecial"
Me.MakeSpecial.Name = "MakeSpecial"
'
'frmForm
'
Me.AutoScaleDimensions = New System.Drawing.SizeF(6.0!, 13.0!)
Me.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font
Me.ClientSize = New System.Drawing.Size(917, 276)
Me.Controls.Add(Me.dgvSpecials)
Me.Controls.Add(Me.btnCreate)
Me.Name = "frmForm"
Me.Text = "frmForm"
CType(Me.dgvSpecials, System.ComponentModel.ISupportInitialize).EndInit()
Me.ResumeLayout(False)

End Sub
Friend WithEvents dgvSpecials As System.Windows.Forms.DataGridView
Friend WithEvents btnCreate As System.Windows.Forms.Button
Friend WithEvents PartCode As System.Windows.Forms.DataGridViewTextBoxColumn
Friend WithEvents PDF As System.Windows.Forms.DataGridViewTextBoxColumn
Friend WithEvents SLDDRW As System.Windows.Forms.DataGridViewTextBoxColumn
Friend WithEvents SLDPRT As System.Windows.Forms.DataGridViewTextBoxColumn
Friend WithEvents BasePartCode As System.Windows.Forms.DataGridViewTextBoxColumn
Friend WithEvents TEMPLATESLDDRW As System.Windows.Forms.DataGridViewTextBoxColumn
Friend WithEvents TEMPLATESLDPRT As System.Windows.Forms.DataGridViewTextBoxColumn
Friend WithEvents TEMPLATEDRWFILE As System.Windows.Forms.DataGridViewTextBoxColumn
Friend WithEvents TEMPLATEPRTFILE As System.Windows.Forms.DataGridViewTextBoxColumn
Friend WithEvents MakeSpecial As System.Windows.Forms.DataGridViewCheckBoxColumn
End Class

这是实际的 frmForm.VB
SldWorks 是 SolidWorks.Interop.sldworks 的成员
Imports SolidWorks.Interop.sldworks

Public Class frmForm
Dim App As SldWorks
Public Sub Setup(App As SldWorks, Arr As ArrayList)

End Sub

Private Sub btnCreate_Click(sender As Object, e As EventArgs) Handles btnCreate.Click

End Sub
End Class

最佳答案

我猜你必须设置MultiSelect DataGridView 的属性为 true

关于vb.net - 无法从 datagridview 复制粘贴,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/22869793/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com