继承DATAGRID的问题,请大家帮忙一下

BookSirSwordsMan 2006-03-17 10:06:50
我想继承DATAGRID控件,然后想要实现可以用上下光标键选择DATAGRID中的数据行,这个如何做呢,请大家帮个忙
...全文
156 11 打赏 收藏 转发到动态 举报
写回复
用AI写文章
11 条回复
切换为时间正序
请发表友善的回复…
发表回复
BookSirSwordsMan 2006-03-18
  • 打赏
  • 举报
回复
真的沒有人可以幫忙嗎,還有沒有其它代碼呀
BookSirSwordsMan 2006-03-18
  • 打赏
  • 举报
回复
既然没人出手,我只好结帖了
BookSirSwordsMan 2006-03-17
  • 打赏
  • 举报
回复
请大家多给点代码吧,到时候结贴我会散分的
job_2006 2006-03-17
  • 打赏
  • 举报
回复
关注,学习....顶
BookSirSwordsMan 2006-03-17
  • 打赏
  • 举报
回复
谢谢jimu8130(IBMT43)你的代码,我想把这个集成到DATAGRID控件中,也就是说直接继承DATAGRID,把这段JS代码加进去,以后要实现功能直接用自己做的DATAGRID就可以了,能帮我实现一下吗,谢谢
jimu8130 2006-03-17
  • 打赏
  • 举报
回复
给你段js代码,
<script language="javascript">
var oldrow;
var currowno=-1;
var strReturn; //存储返回值
var newColor='#ffcc66';
var oldColor;
var MaxRowCount;
function SelectOK(text)
{
eval("parent.opener.document.all.TextBox1.value = text");
parent.close();
}
function ChangePage(KeyCode)
{
document.all('DataGrid1').focus();
if ( KeyCode == 33 ) { // 定义 PageUp 键快捷功能
document.all.PrevPage.click();
}
if ( KeyCode == 34 ) { // 定义 PageDown 键快捷功能
document.all.NextPage.click();
}
if ( KeyCode == 36 ) { // 定义 Home 键快捷功能
document.all.FirstPage.click();
}
if ( KeyCode == 35 ) { // 定义 End 键快捷功能
document.all.LastPage.click();
}
if ( KeyCode == 38 ) { // ↑ 键快捷功能

if(currowno==0)//如果已经为第0行,则跳到txtFilter中
{
currowno=-1;//设置未为选中状态
document.all('ROW0').style.backgroundColor=oldColor;
document.all.txtFilter.focus();
}
else
{
MoveUp();
}

}
if ( KeyCode == 40 ) { // ↓ 键快捷功能
if(currowno==-1)//如果还没有选中Grid中的行,则设置Grid的第0行为选中状态
{
if(document.all('ROW0')!=null)
document.all('ROW0').click();
else
document.all.txtFilter.focus();
}
else
{
MoveDown();
}
}
if ( KeyCode == 37 ) { // ← 键快捷功能( 上一层 )
//QueryParent();
}
if ( KeyCode == 39 ) { // → 键快捷功能( 下一层 )
//QueryChild();
}
if ( KeyCode == 13 ) { // 回车键

if(event.srcElement.name=='txtFilter')
{
document.all.LastPage.disabled = true;
document.all.FirstPage.disabled = true;
document.all.PrevPage.disabled = true;
document.all.NextPage.disabled = true;
document.all.GotoPage.disabled = true;
}
else
{
if(currowno!=-1)
{
document.all.LastPage.disabled = true;
document.all.FirstPage.disabled = true;
document.all.PrevPage.disabled = true;
document.all.NextPage.disabled = true;
document.all.btnFilteData.disabled = true;
document.all.GotoPage.disabled = true;
GotoMain(strReturn);
}
}
}
}
function RowFocus(rowno,strValue)
{
if(currowno!=-1){
oldrow.style.backgroundColor=oldColor;
}
strReturn = strValue;
oldColor=document.all('ROW' + rowno).style.backgroundColor;
oldrow=document.all('ROW' + rowno);

document.all('ROW' + rowno).style.backgroundColor= newColor;
currowno=rowno;
}
function MoveUp() {
if(currowno!=-1)
{
if(currowno==0)
currowno=MaxRowCount-1;
else
currowno=currowno-1;

document.all('ROW' + currowno).click();
}
else
document.all.txtFilter.focus();

}

function MoveDown() {
if(currowno==MaxRowCount-1)
currowno=0;
else
currowno=currowno+1;

document.all('ROW' + currowno).click();

}
</script>
<script language="JavaScript" event="onkeydown" for="document">
if ( event.keyCode == 34 || event.keyCode == 33 || event.keyCode == 35 || event.keyCode == 36 || event.keyCode == 37 || event.keyCode == 38 || event.keyCode == 39 || event.keyCode == 40 || event.keyCode == 13 )
{
ChangePage(event.keyCode);
}
if ( event.keyCode == 27 )
{
history.go(-1);
}

</script>
SeeSunSet 2006-03-17
  • 打赏
  • 举报
回复
自己写ActiveX吧.把CS的DATAGRID搬过来.
BookSirSwordsMan 2006-03-17
  • 打赏
  • 举报
回复
因为做B/S方面的系统的话,系统有特殊要求,要用全键盘操作,尽量不用鼠标
job_2006 2006-03-17
  • 打赏
  • 举报
回复
.....................有什么意义??
BookSirSwordsMan 2006-03-17
  • 打赏
  • 举报
回复
我说的这个DATAGRID是WEB页面上的
liefeng123 2006-03-17
  • 打赏
  • 举报
回复
用htc把js封装起来实现
怎么样?

62,025

社区成员

发帖
与我相关
我的任务
社区描述
.NET技术交流专区
javascript云原生 企业社区
社区管理员
  • ASP.NET
  • .Net开发者社区
  • R小R
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告

.NET 社区是一个围绕开源 .NET 的开放、热情、创新、包容的技术社区。社区致力于为广大 .NET 爱好者提供一个良好的知识共享、协同互助的 .NET 技术交流环境。我们尊重不同意见,支持健康理性的辩论和互动,反对歧视和攻击。

希望和大家一起共同营造一个活跃、友好的社区氛围。

试试用AI创作助手写篇文章吧