导航:首页 > 净水问答 > vblistview过滤

vblistview过滤

发布时间:2022-07-22 04:08:36

① vbnet中listview控件输入中文重复引发Keypress事件

如果是单个字的重复还好说,可是输入词组时,一串字的重复,而且一个字一次事件,这肯定是微软的一个Bug。

办法是有的,把中文字暂时放入字符缓冲中,遇到成双时对半分,前后对比一下,如果相同表示这次输入完成。


PrivateSubListView1_KeyPress(ByValsenderAsObject,ByValeAsSystem.Windows.Forms.KeyPressEventArgs)HandlesListView1.KeyPress
StaticbufferAsString
Staticar(1)AsString
IfAsc(e.KeyChar)<0Then
buffer&=e.KeyChar
Ifbuffer.LengthMod2=0Then
ar(0)=buffer.Substring(0,buffer.Length2)
ar(1)=buffer.Substring(buffer.Length2)
Ifar(0)=ar(1)Then
Debug.Print(ar(0))'输出中文
buffer=Nothing
EndIf
EndIf
Else
Debug.Print(e.KeyChar)'输出英文
EndIf
EndSub

② VB如何筛选listview里的内容

也就是查找LISTVIEW控件中指定的字符串吧.

Private Sub ListView2_Click()
On Error GoTo ONERROR
Dim strFindMe As String

strFindMe = ListView2.ListItems(ListView2.SelectEditem.Index).Text 获取选定行的第一列的文本

FindItem 方法返回找到的项目的引用,所以必须创建对象变量并将找到的项目设置给它。
Dim itmFound As ListItem “FoundItem 变量”

Set itmFound = ListView1.FindItem(strFindMe, lvwText, , lvwPartial)

若未找到符合条件的 ListItem 则通知用户并退出。如果找到 ListItem,则使用 EnsureVisible 方法滚动控件,并选定 ListItem。
If itmFound Is Nothing Then 若没有匹配成功,则通知用户并退出。
MsgBox "No match found"
Else
itmFound.EnsureVisible 滚动 ListView 以显示找到的 ListItem。
itmFound.Selected = True 选定ListItem。
ListView1.SetFocus 将焦点返回给控件以查看选择。
End If
Set itmFound = Nothing
ONERROR:
If Err.Number <> 0 Then
Select Case Err.Number
Case Else
MsgBox "错误代码:" & Err.Number & " 错误描述:" & Err.Description, vbExclamation, App.ExeName
Resume Next
End Select
End If
End Sub

③ VB Listview控件怎么去掉不需要的列

加上下面的代码:
ListView1.ColumnHeaders.Item(1).Width = 0 '< ---第1列宽设置为0
ListView1.ColumnHeaders.Item(2).Width = 1000 '< ---第2列宽
ListView1.ColumnHeaders.Item(3).Width = 500 ' < ---第3列宽
ListView1.ColumnHeaders.Item(4).Width = 1500 '< ---第4列宽
ListView1.ColumnHeaders.Item(5).Width = 1000 '< ---第5列宽
ListView1.ColumnHeaders.Item(6).Width = 0 '< ---第6列宽设置为0
ListView1.ColumnHeaders.Item(7).Width = 0 '< ---第7列宽设置为0
请采纳,谢谢!

④ vb 中 listview 的用法

可以以数组下标访问。ListView.Items[i].text;

//增加
i := ListView1.Items.Count;
with ListView1 do
begin
ListItem:=Items.Add;
ListItem.Caption:= IntToStr(i);
ListItem.SubItems.Add('第 '+IntToStr(i)+' 行');
ListItem.SubItems.Add('第三列内容');
end;

//按标题删除
for i:=ListView1.Items.Count-1 downto 0 Do
if ListView1.Items[i].Caption = Edit1.Text then
begin
ListView1.Items.Item[i].Delete(); //删除当前选中行
end;

//选中一行
if ListView1.Selected <> nil then
Edit1.Text := ListView1.Selected.Caption;

// listview1.Items[Listview1.Items.Count -1].Selected := True;
// listview1.Items[Listview1.Items.Count -1].MakeVisible(True);
procere TForm1.Button2Click(Sender: TObject); // 选择第一条
begin
listview1.SetFocus;
listview1.Items[0].Selected := True;
end;

procere TForm1.Button1Click(Sender: TObject); // 选择最后一条
begin
listview1.SetFocus;
listview1.Items[Listview1.Items.Count -1].Selected := True;
end;

//这是个通用的过程
procere ListViewItemMoveUpDown(lv : TListView; Item : TListItem; MoveUp, SetFocus : Boolean);
var
DestItem : TListItem;
begin
if (Item = nil) or
((Item.Index - 1 < 0) and MoveUp) or
((Item.Index + 1 >= lv.Items.Count) and (not MoveUp))
then Exit;
lv.Items.BeginUpdate;
try
if MoveUp then
DestItem := lv.Items.Insert(Item.Index - 1)
else
DestItem := lv.Items.Insert(Item.Index + 2);
DestItem.Assign(Item);
lv.Selected := DestItem;
Item.Free;
finally
lv.Items.EndUpdate;
end;
if SetFocus then lv.SetFocus;
DestItem.MakeVisible(False);
end;

//此为调用过程,可以任意指定要移动的Item,下面是当前(Selected)Item
ListViewItemMoveUpDown(ListView1, ListView1.Selected, True, True);//上移
ListViewItemMoveUpDown(ListView1, ListView1.Selected, False, True);//下移

TListView组件使用方法

引用CommCtrl单元

procere TForm1.Button1Click(Sender: TObject);
begin
ListView_DeleteColumn(MyListView.Handle, i);//i是要删除的列的序号,从0开始

end;

用LISTVIEW显示表中的信息:
procere viewchange(listv:tlistview;table:tcustomadodataset;var i:integer);
begin
tlistview(listv).Items.BeginUpdate; {listv:listview名}
try
tlistview(listv).Items.Clear;
with table do {table or query名}
begin
active:=true;
first;
while not eof do
begin
listitem:=tlistview(listv).Items.add;
listitem.Caption:=trim(table.fields[i].asstring);
// listitem.ImageIndex:=8;
next;
end;
end;
finally
tlistview(listv).Items.EndUpdate;
end;
end;

ListView使用中的一些要点。以下以一个两列的ListView为例。
→增加一行:
with ListView1 do
begin
ListItem:=Items.Add;
ListItem.Caption:='第一列内容';
ListItem.SubItems.Add('第二列内容');
end;
→清空ListView1:
ListView1.Items.Clear;
→得到当前被选中行的行的行号以及删除当前行:
For i:=0 to ListView1.Items.Count-1 Do
If ListView1.Items[i].Selected then //i=ListView1.Selected.index
begin
ListView1.Items.Delete(i); //删除当前选中行
end;
当然,ListView有OnSelectItem事件,可以判断选择了哪行,用个全局变量把它赋值出来。
→读某行某列的操作:
Edit1.Text := listview1.Items[i].Caption; //读第i行第1列
Edit2.Text := listview1.Items[i].SubItems.strings[0]; //读第i行第2列
Edit3.Text := listview1.Items[i].SubItems.strings[1]; //读第i行第3列
以次类推,可以用循环读出整列。
→将焦点上移一行:
For i:=0 to ListView1.Items.Count-1 Do
If (ListView1.Items[i].Selected) and (i>0) then
begin
ListView1.SetFocus;
ListView1.Items.Item[i-1].Selected := True;
end;
不过在Delphi6中,ListView多了一个ItemIndex属性,所以只要
ListView1.SetFocus;
ListView1.ItemIndex:=3;
就能设定焦点了。

⑤ VB中怎么清空listview中的东西

用ListView.ListItems.Clear清空所有项目;用ListView.ColumnHeaders.Clear清空表头。

示例代码如下:

(1)新建一个VB6工程

(2)在Form1窗体布置一个ListView和一个Command

⑥ vb.net中,怎么把listview1的数据筛选之后放到listview2,不能删除listview1的数据

ListView2.Items.Add(ListView1.Items(0).Clone)

⑦ vb listview筛选删除

要解决这个问题主要是要掌握listview这个控件的用法。大致了解下后重点解决:1.listview如何遍历数据 2.listview删除某行的方法。

获取当前行数和列数:

读取某行第几列内容 (不包括第一列):

循环查找读取项目:

删除指定行:

网页链接

⑧ VB中listview的用法

文本文件 1.txt
里面内容是:
李佳
22
文秘
13655555555
张奇
24
经理
13755555555
张佳
22

135555555

Public Sub LVrefresh(Optional ByVal StandardType As Boolean)
Dim intRow As Integer, strTemp As String
Dim fileNo As Integer, fileName As String
Dim Fp As New FileSystemObject
Dim strTs As TextStream

Dim ListItemTemp As ListItem

On Error Resume Next

fileNo = FreeFile

With ListView1
.ColumnHeaders.Clear
.ListItems.Clear

.ColumnHeaders.Add , , "姓名"
.ColumnHeaders(1).Width = 1200
.ColumnHeaders.Add , , "年龄"
.ColumnHeaders(2).Width = 900
.ColumnHeaders.Add , , "职位"
.ColumnHeaders(3).Width = 2000
.ColumnHeaders.Add , , "联系电话"
.ColumnHeaders(4).Alignment = lvwColumnLeft
.ColumnHeaders(4).Width = 2000

intRow = 1

fileName = IIf(Left(App.Path, 1) = "\", App.Path & "1.txt", App.Path & "\1.txt")

Set strTs = Fp.OpenTextFile(fileName)

strTemp = strTs.ReadLine

Do While Err.Number = 0

If intRow = 1 Then
Set ListItemTemp = .ListItems.Add(, , strTemp)
Else
ListItemTemp.SubItems(intRow - 1) = strTemp
End If

If intRow = 4 Then
intRow = 1
Else
intRow = intRow + 1
End If
strTemp = strTs.ReadLine
Loop

End With
End Sub

Private Sub Command1_Click()
LVrefresh
End Sub

⑨ vb中怎么从listview框的记录中筛选

Private Sub Command1_Click()
If List1.List(List1.ListIndex) <> "" Then
List2.AddItem (List1.List(List1.ListIndex))
List1.RemoveItem (List1.ListIndex)
End If
End Sub

Private Sub Command2_Click()
If List2.List(List2.ListIndex) <> "" Then
List1.AddItem (List2.List(List2.ListIndex))
List2.RemoveItem (List2.ListIndex)
End If
End Sub

Private Sub Form_Load()
List1.AddItem "A"
List1.AddItem "B"
List1.AddItem "C"
List1.AddItem "D"
List1.AddItem "E"
Command1.Caption = "添加"
Command2.Caption = "删除"
End Sub

完整代码如上,你只需在窗体上添加四个控件:
两个ListBox和两个CommandBox
无须修改代码,直接运行即可.

⑩ vb中控件listview的详细使用

1、首先,点击文件->新建->项目,打开项目创建视窗,切换到Visual Basic,选择Windows窗体应用程序,新建一个。

阅读全文

与vblistview过滤相关的资料

热点内容
污水管线先安管后浇筑检查井 浏览:431
pvc树脂和pvc糊树脂的区别 浏览:591
罐体式污水处理零件更换周期 浏览:862
速腾净水器不上水是什么原因啊 浏览:681
mc全世界都是核废水该怎么生存 浏览:876
老式沁园饮水机多少钱 浏览:907
利尊潜水污水泵价格 浏览:260
东风m3的空气滤芯在哪里 浏览:66
饮水机里出来的絮状东西是什么 浏览:29
杭州污水池环氧防腐漆价格 浏览:732
如何提升路由器上传速度 浏览:117
超滤净水设备厂商代理 浏览:827
edi按功能分为有哪几种 浏览:634
惠普康反渗透纯水机 浏览:226
空气滤芯是滤什么的 浏览:124
长按出水的饮水机怎么按 浏览:872
水处理工理论知识 浏览:602
大家都放不开纯净水什么意思 浏览:215
容声净水器308多少钱 浏览:37
钛棒过滤芯使用寿命 浏览:585