在vb.net中,datagrid视图鼠标左键单击 [英] datagrid view mouse left click in vb.net
本文介绍了在vb.net中,datagrid视图鼠标左键单击的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
嗨!
我正在做一个有数据网格的程序.当我单击鼠标左键时,我希望该单元格是可编辑的.谁能帮我如何处理鼠标左键单击?谢谢!
Hi!
I''m doing a program it has a datagrid. I want the cell to be editable when i click the mouse left click. Can anyone help me how to handle the mouse left click? Thanks!
推荐答案
参考:
^ ]
根据您的需要,您可以将该javascript修改为
< script src ="http://ajax.aspnetcdn.com/ajax/jQuery/jquery-1.6.js" type ="text/javascript"></script>
< script type ="text/javascript">
Refer:
http://forums.asp.net/p/1737637/4676456.aspx/1?Re+GRIDVIEW+CELL+MOUSE+LEFT+CLICK+AND+RIGHT+CLICK+EVENTS+IN+JAVASCRIPT+FUNCTIONALITY[^]
As per your need you can modify that javascript as
<script src="http://ajax.aspnetcdn.com/ajax/jQuery/jquery-1.6.js" type="text/javascript"></script>
<script type="text/javascript">
(文档).ready(function(){
(document).ready(function () {
("table [id * = GridView1] td ).mousedown(function(){
如果(event.button == 1){
form1.action ="WebForm2.aspx?action = UnEdit";
form1.submit();
}
其他
{form1.action ="WebForm2.aspx?action = Edit";
form1.submit();
}
});
});并在代码背后:
受保护的子Page_Load(以对象的ByBy发件人身份,以System.EventArgs的ByVal e身份)处理Me.Load
如果Request.QueryString("action")="Edit"然后
GridView1.AutoGenerateEditButton ="true"
如果结束
如果Request.QueryString("action")="UnEdit"然后
GridView1.AutoGenerateEditButton ="false"
如果结束
结束Sub
("table[id*=GridView1] td").mousedown(function () {
if (event.button == 1) {
form1.action = "WebForm2.aspx?action=UnEdit";
form1.submit();
}
else
{ form1.action = "WebForm2.aspx?action=Edit";
form1.submit();
}
});
});And in codebehind:
Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
If Request.QueryString("action") = "Edit" Then
GridView1.AutoGenerateEditButton = "true"
End If
If Request.QueryString("action") = "UnEdit" Then
GridView1.AutoGenerateEditButton = "false"
End If
End Sub
这篇关于在vb.net中,datagrid视图鼠标左键单击的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文