专注于gridview,在gridview外部的文本框中按下箭头键 [英] focus on gridview on pressing down arrow key on a textbox outside the gridview

查看:83
本文介绍了专注于gridview,在gridview外部的文本框中按下箭头键的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

与使用C#的Asp.net 3.5相关的问题

我在gridview的顶部有一个文本框,当我按一个键时,gridview充满了与文本框中的文本相关的数据.
现在我必须用鼠标单击gridview才能在gridview中使用箭头键上下移动.
我想要当我在文本框中按下向下箭头键时,自动单击gridview的第一行,并将焦点移到第一行(如果存在)

有帮助吗?

谢谢
Faiz

Question Related to Asp.net 3.5 using C#

I have a textbox at the top of a gridview, when i press a key, the gridview filled with the data related to the text in the textbox.
now i have to click the gridview with mouse to go up and down with arrow keys within the gridview.
I want, that when i press down arrow key in the textbox the first row of the gridview is automatically get clicked and the focus goes to the first row(if exist)

Any help?

thanks
Faiz

推荐答案

嗨Faiz,

您将无法直接从任何.net类中获取此信息,如果您使用任何第三方gridview或ajax,这将非常困难.但是,如果您尝试使用基本功能,您将能够做到这一点.

在keypress事件中捕获键,然后将所选行增加1.

Hi Faiz,

You won''t be able to get this directly from any of the .net class and it will be difficult if you are using any 3rd party gridview or ajax. But you will able to do so if you try with the basic.

in keypress event catch the key and then increment the selected row by 1.

TextBox1.Attributes.Add("OnKeyPress", "GetKeyPress()")

In the Default.ASPX Code page, I have

<script>

Function GetKeyPress()
{
    alert("you Pressed " & event.KeyCode;
}

</script>



现在,在此函数中,您可以使用类似这样的内容



now within this function you can use something like this

GridView gv = new GridView();
       GridViewRow r = gv.SelectedRow; // handel case when no row is selected
       // set the new focus to new row

       gv.SelectedRow.RowIndex = r.RowIndex + 1;



这可能现在就可以了,因为我还没有在VS上做到这一点.如果有任何问题,请尝试让我知道.

祝一切顺利!



this might now work as of now because i havent done this on VS .. please try and let me know in case of any issue.

All the best!!


这篇关于专注于gridview,在gridview外部的文本框中按下箭头键的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆