分享一下我老师大神的人工智能教程吧。零基础!通俗易懂!风趣幽默!还带黄段子!希望你也加入到我们人工智能的队伍中来!http://www.captainbed.net
在.Net中的应用
1、定位指定控件
/// <summary>
/// 定位txtCode控件
/// </summary>
private void Scroll()
{
string s="<script>function window.onload(){document.all('"+this.txtCode.ClientID+"').scrollIntoView();}</script>";
Page.RegisterStartupScript("",s);
}
2、定位指定DataGrid列
<
div
style
="BORDER:0px;PADDING:0px;MARGIN:0px;OVERFLOW:scroll;WIDTH:600px;HEIGHT:200px"
align
="center"
>
现在给出一种简单的办法(其他的一些利用锚点等办法都比较复杂)
private
void
Scroll(
int
index)
{
string s="<script>function window.onload() {document.all('"+this.DataGrid1.ClientID+"').rows["+index+"].scrollIntoView();}</script>";
Page.RegisterStartupScript("",s);
}
{
string s="<script>function window.onload() {document.all('"+this.DataGrid1.ClientID+"').rows["+index+"].scrollIntoView();}</script>";
Page.RegisterStartupScript("",s);
}
写了一个方法,其中DataGrid1换成自己的DataGrid的ID,这个方法传递进去的参数就是行号,也就是e.Item.ItemIndex。
比如在编辑操作的时候会写this.DataGrid1.EditItemIndex=e.Item.ItemIndex;
在此语句的以前加入Scroll(e.Item.ItemIndex);就可以了
同样在更新操作的时候写为Scroll(e.Item.ItemIndex);this.DataGrid1.EditItemIndex=-1;绑定;
再分享一下我老师大神的人工智能教程吧。零基础!通俗易懂!风趣幽默!还带黄段子!希望你也加入到我们人工智能的队伍中来!http://www.captainbed.net