【在线等】C# Web 如何使 textBox 显示最下面的内容?

benbenRH 2008-11-14 10:07:14
如题,像QQ发信息后显示最下面的内容,
...全文
228 9 打赏 收藏 转发到动态 举报
写回复
用AI写文章
9 条回复
切换为时间正序
请发表友善的回复…
发表回复
路人乙e 2008-11-15
  • 打赏
  • 举报
回复
var obj=document.getElementById("textbox1");
setInterval(function(){obj.scrollTop=obj.scrollHeight;},100};
lovehongyun 2008-11-15
  • 打赏
  • 举报
回复
web要在客户端用脚本来实现.

与c#无关.
Joschime 2008-11-15
  • 打赏
  • 举报
回复
up
diffmaker 2008-11-15
  • 打赏
  • 举报
回复
在Web中可以通过前台模拟的方法实现吧


<%@ Page Language="C#" AutoEventWireup="true" CodeFile="Default.aspx.cs" Inherits="_Default" %>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html xmlns="http://www.w3.org/1999/xhtml" >
<head runat="server">
<title>无标题页</title>
<script type="text/javascript">
var iscroll;
function scrollobj(){
var obj=document.getElementById("tbSample");
obj.doScroll("pageDown");
}
function beginscroll(){
var obj=document.getElementById("autoscroll");
if(obj.checked)
iscroll = setInterval("scrollobj()", 10);
else
clearInterval(iscroll);
}
window.onload=beginscroll;
</script>
</head>
<body>
<form id="form1" runat="server">
<asp:TextBox ID="tbSample" runat="server" Height="168px" TextMode="MultiLine" Width="365px"></asp:TextBox>
<br />
<input id="autoscroll" type="checkbox" checked="CHECKED" onclick="beginscroll();" />自动滚动
</form>
</body>
</html>


这个与C#没有什么关系
benbenRH 2008-11-14
  • 打赏
  • 举报
回复
我的是 C# web来的 ,你的是不是winForm啊?
qishichang 2008-11-14
  • 打赏
  • 举报
回复
string s="aaaa";
textBox1.SelectedText += s + "\r\n";
textBox1.ScrollToCaret();
benbenRH 2008-11-14
  • 打赏
  • 举报
回复
[Quote=引用 1 楼 hornbills 的回复:]
C# code

this.textBox1.SelectionStart = this.textBox1.Text.Length;
this.textBox1.ScrollToCaret();



[/Quote]

怎么我的没有SelectionStart这个属性的?
Jeff20040819 2008-11-14
  • 打赏
  • 举报
回复
up
hornbills 2008-11-14
  • 打赏
  • 举报
回复

this.textBox1.SelectionStart = this.textBox1.Text.Length;
this.textBox1.ScrollToCaret();

110,534

社区成员

发帖
与我相关
我的任务
社区描述
.NET技术 C#
社区管理员
  • C#
  • Web++
  • by_封爱
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告

让您成为最强悍的C#开发者

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