selecteditems,删除的时候,显示 The selected items are in use. 怎么处理
各位朋友,你是否对selecteditems和删除的时候,显示 The selected items are in use. 怎么处理的相关问题感到好奇?别担心,我将为你揭示这些问题的答案,帮助你更好地理解和应用这些知识。让我们一起探索吧!
excel中怎样读取另一个文件
第一种方法:打开另一个文件,copy,paste:
触发按钮单机事件,VBA如下:
[code=vb]
Private Sub CommandButton1_Click()
Dim towb As Workbook
Dim tows As Worksheet
Dim torow As Integer
Dim fromwb As Workbook
Dim fromws As Worksheet
Dim fromrow As Integer
Dim projectname
Dim i
Dim openfiles'input the filepath of your selection
Set towk= Application.ActiveWorkbook
Set tows= ActiveSheet
torow= [a65536].End(3).Row+ 1'get the last row of data by column A
'get the active worksheet
'call openfile function
openfiles= openfile()
If openfiles<>"" Then
Set fromwb= Application.Workbooks.Open(openfiles)
Set fromws= fromwb.Sheets("IPIS")
'set ID
tows.Activate
tows.Cells(torow, 1)= tows.Cells(torow- 1, 1)+ 1
'set"Go/No Go"
tows.Activate
tows.Cells(torow, 2)="Go"
'set"Project Name"
fromwb.Activate
fromws.Activate
fromws.Cells(5, 1).Select
Selection.Copy
tows.Activate
tows.Cells(torow, 7).Select
Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks _
:=False, Transpose:=False
projectname= tows.Cells(torow, 7)
'set"Customer" by projectname
tows.Activate
tows.Cells(torow, 4)= Split(projectname,"", 2)(0)
' range("A1") Like"*1234*"
End If
towk.Activate
End Sub
Function openfile() As Variant
'Declare a variable as a FileDialog object.
Dim fd As FileDialog
'Create a FileDialog object as a File Picker dialog box.
Set fd= Application.FileDialog(msoFileDialogFilePicker)
'Declare a variable to contain the path
'of each selected item. Even though the path is aString,
'the variable must be a Variant because For Each...Next
'routines only work with Variants and Objects.
Dim vrtSelectedItem As Variant
'Use a With...End With block to reference the FileDialog object.
With fd
'Allow the selection of multiple files.
.AllowMultiSelect= True
'Use the Show method to display the file picker dialog and return the user's action.
'If the user presses the button...
If.Show=-1 Then
'Step through each string in the FileDialogSelectedItems collection.
For Each vrtSelectedItem In.SelectedItems
'vrtSelectedItem is aString that contains the path of each selected item.
'You can use any file I/O functions that you want to work with this path.
'This example displays the path in a message box.
MsgBox"Selected item's path:"& vrtSelectedItem
openfile= vrtSelectedItem
Next
'If the user presses Cancel...
Else
End If
End With
'Set the object variable to Nothing.
Set fd= Nothing
End Function
[/code]
总结:这种方法可以实现,但是需要打开对应的选择文件才行.
第二种方法:利用引用来显示另一个表的内容,不打开文件,VBA代码如下:
触发按钮单机事件:
[code=vb]
Private Sub CommandButton1_Click()
Dim towb As Workbook
Dim tows As Worksheet
Dim torow As Integer
Dim fromwb As Workbook
Dim fromws As Worksheet
Dim fromrow As Integer
Dim projectname
Dim i
Dim openfiles'input the filepath of your selection
Dim filename
Set towk= Application.ActiveWorkbook
Set tows= ActiveSheet
torow= [a65536].End(3).Row+ 1'get the last row of data by column A
'get the active worksheet
Application.ScreenUpdating= False'call openfile function
openfiles= openfile()
If openfiles<>"" Then
'Set fromwb= Application.Workbooks.Open(openfiles)
'Set fromws= fromwb.Sheets("IPIS")
'set ID
tows.Activate
tows.Cells(torow, 1)= tows.Cells(torow- 1, 1)+ 1
'set"Go/No Go"
tows.Activate
tows.Cells(torow, 2)="Go"
'set"Project Name"
filename= dealstr(openfiles)
ActiveSheet.Cells(torow, 7).Formula="='"& filename&"IPIS'!$A$5"
projectname= tows.Cells(torow, 7)
'set"Customer" by projectname
tows.Activate
tows.Cells(torow, 4)= Split(projectname,"", 2)(0)
' range("A1") Like"*1234*"
End If
towk.Activate
Application.ScreenUpdating= True
End Sub
Function dealstr(f As Variant) As Variant
Z= Len(f)
For ii= Z To 1 Step-1
If Mid(f, ii, 1)="\" Then
Exit For
End If
Next ii
For i= Len(f) To y Step-1
If Mid(f, i, 1)<="z" Then
Exit For
End If
Next i
a= Mid(f, ii+ 1, i- ii)
b= Mid(f, 1, ii)
dealstr= b&"["& a&"]"
End Function
Function openfile() As Variant
'Declare a variable as a FileDialog object.
Dim fd As FileDialog
'Create a FileDialog object as a File Picker dialog box.
Set fd= Application.FileDialog(msoFileDialogFilePicker)
'Declare a variable to contain the path
'of each selected item. Even though the path is aString,
'the variable must be a Variant because For Each...Next
'routines only work with Variants and Objects.
Dim vrtSelectedItem As Variant
'Use a With...End With block to reference the FileDialog object.
With fd
'Allow the selection of multiple files.
.AllowMultiSelect= True
'Use the Show method to display the file picker dialog and return the user's action.
'If the user presses the button...
If.Show=-1 Then
'Step through each string in the FileDialogSelectedItems collection.
For Each vrtSelectedItem In.SelectedItems
'vrtSelectedItem is aString that contains the path of each selected item.
'You can use any file I/O functions that you want to work with this path.
'This example displays the path in a message box.
openfile= vrtSelectedItem
Next
'If the user presses Cancel...
Else
End If
End With
'Set the object variable to Nothing.
Set fd= Nothing
End Function
[/code]
总结:这种方法,不用再打开选择的文件,但是,利用引用的方式显示另一个文件的内容,显得有些藕断丝连,不方便.
第三种方法:利用ExecuteExcel4Macro,不打开文件就能读取内容,不再是引用的关系,VBA代码如下:
触发按钮单机事件:
[code=vb]Private Sub CommandButton1_Click()
Dim towb As Workbook
Dim tows As Worksheet
Dim torow As Integer
Dim cnn As New ADODB.Connection
Dim rs As New ADODB.Recordset
Dim i As Integer
Dim SQL As String, cnnStr As String, sFileName As String
Dim wb As Workbook
Dim ws As Worksheet
Dim projectname
Dim openfiles'input the filepath of your selection
Dim filename
Set towk= Application.ActiveWorkbook
Set tows= ActiveSheet
torow= [a65536].End(3).Row+ 1'get the last row of data by column A
'get the active worksheet
Application.ScreenUpdating= False'call openfile function
openfiles= openfile()
If openfiles<>"" Then
If GetValue(getpathname(openfiles), getfilename(openfiles),"IPIS","A2")="error" Then
MsgBox"选取文件有误"
Else
'set ID
tows.Activate
tows.Cells(torow, 1)= tows.Cells(torow- 1, 1)+ 1
'set"Go/No Go"
tows.Activate
tows.Cells(torow, 2)="Go"
'set"Project Name"
tows.Cells(torow, 7)= GetValue(getpathname(openfiles), getfilename(openfiles),"IPIS","A5")
projectname= tows.Cells(torow, 7)
'set"Customer" by projectname
tows.Activate
tows.Cells(torow, 4)= Split(projectname,"", 2)(0)
End If
End If
Application.ScreenUpdating= True
End Sub
Private Function GetValue(path, filename, sheet, ref)
'从关闭的工作薄返回值
Dim MyPath As String
'确定文件是否存在
If Right(path, 1)<>"\" Then path= path&"\"
If Dir(path& filename)="" Then
GetValue="error"
Exit Function
End If
'创建公式
MyPath="'"& path&"["& filename&"]"& sheet&"'!"& Range(ref).Range("A1").Address(,, xlR1C1)
'执行EXCEL4宏函数
GetValue= Application.ExecuteExcel4Macro(MyPath)
End Function
Function openfile() As Variant
'Declare a variable as a FileDialog object.
Dim fd As FileDialog
'Create a FileDialog object as a File Picker dialog box.
Set fd= Application.FileDialog(msoFileDialogFilePicker)
'Declare a variable to contain the path
'of each selected item. Even though the path is aString,
'the variable must be a Variant because For Each...Next
'routines only work with Variants and Objects.
Dim vrtSelectedItem As Variant
'Use a With...End With block to reference the FileDialog object.
With fd
'Allow the selection of multiple files.
.AllowMultiSelect= True
'Use the Show method to display the file picker dialog and return the user's action.
'If the user presses the button...
If.Show=-1 Then
'Step through each string in the FileDialogSelectedItems collection.
For Each vrtSelectedItem In.SelectedItems
'vrtSelectedItem is aString that contains the path of each selected item.
'You can use any file I/O functions that you want to work with this path.
'This example displays the path in a message box.
openfile= vrtSelectedItem
Next
'If the user presses Cancel...
Else
End If
End With
'Set the object variable to Nothing.
Set fd= Nothing
End Function
Function getfilename(f As Variant) As Variant
Z= Len(f)
For ii= Z To 1 Step-1
If Mid(f, ii, 1)="\" Then
Exit For
End If
Next ii
For i= Len(f) To y Step-1
If Mid(f, i, 1)<="z" Then
Exit For
End If
Next i
getfilename= Mid(f, ii+ 1, i- ii)
End Function
Function getpathname(f As Variant) As Variant
Z= Len(f)
For ii= Z To 1 Step-1
If Mid(f, ii, 1)="\" Then
Exit For
End If
Next ii
For i= Len(f) To y Step-1
If Mid(f, i, 1)<="z" Then
Exit For
End If
Next i
getpathname= Mid(f, 1, ii)
End Function
[/code]
总结:感觉还是这种方式比较好~
删除的时候,显示 The selected items are in use. 怎么处理
删除的时候,显示 The selected items are in use是所请求的资源正在使用中
首先确认是不是系统文件,由其是隐藏文件,如果是,是删除不了的,有时删除还会出现。
删除不了的软件、文件或文件夹的解决方法:
1、开机按F8不动,到高级选项出现在松开手,用上下键选安全模式,按照提示进入到安全模式中删除即可(安全模式与正常模式操作一样)。
2、如果使用其他办法无法删除可选择Unlocker强行删除工具删除,安装后右键点要删除的文件选择Unlocker再选删除就可以将要删除的文件彻底删除(类似的软件有QQ电脑管家、360卫士、金山卫士有粉碎文件功能)。
c# winform中listview的item点击事件
基本上,要显示数据库的资料应该用DataGridView比ListView来的好。
不过你用的是ListView,所以我还是讲ListView。
~ListView设定建议~
建议你把ListView的检视模式设为details
然後把ListView.FullRowSelect属性设为true
因为你要一次选中所有行,然後把每个行的值显示到对应的Textbox
~代码设定~
假设ListView的名字为lv,然後有以下这三个项目,他们在ListView中从左到右的排序为:
名字、年龄、性别
接著,他们各自对应的Textbox名字为:
txtName, txtAge, txtSex
~开始撰写代码~
你要把代码写在ListView的lClick事件裏头。
代码是这样写的:
privatevoidlv_Click(objectsender,EventArgse)//lv的Click事件。
{
intselectCount=lv.SelectedItems.Count;//SelectedItems.Count就是:取得值,表示SelectedItems集合的物件数目。
if(selectCount>0)//若selectCount大於0,说明用户有选中某列。
{
txtName.Text=lv.SelectedItems[0].SubItems[0].Text;
txtAge.Text=lv.SelectedItems[0].SubItems[1].Text;
txtSex.Text=lv.SelectedItems[0].SubItems[2].Text;
}
}
如果有问题在问我!
如果我答得出来就回答你!
关于selecteditems到此分享完毕,希望能帮助到您。