看见你的帖子 请教QT中QTextBrowser控件的用法 http:zhidao.baidu.comquestion291810412.html

看见你的帖子 请教QT中QTextBrowser控件的用法 http:zhidao.baidu.comquestion291810412.html,第1张

其实实现起来也不是很复杂,主要是自append一段文字之后,记录下来这一次append的block的行数,既然你知道了位置,选择或删除的话就容易了,贴一段代码供参考:

static int lastBlockCount = 0; //最后一次文本总行数

int iCount = uichat_edit->document()->blockCount(); //当前插入之后的总行数

m_msgLinespush(iCount-lastBlockCount);//m_msgLines是一个队列,保存当前插入字符行数

lastBlockCount = iCount;

//超过阀值,删除10条

if (m_msgLinessize()>100)

{

int iLines = 0;

for (int i=0; i<10; i++)

{

iLines += m_msgLinesfront();

m_msgLinespop();

}

QTextCursor cs=uichat_edit->textCursor();

csmovePosition(QTextCursor::Start, QTextCursor::MoveAnchor);

csmovePosition(QTextCursor::NextBlock,QTextCursor::KeepAnchor, iLines);

csremoveSelectedText();

lastBlockCount -= iLines;

}

你好,软糖来回答把。

代码已通过测试。

一、获取第一个匹配行

public void 查找特定行() {

    // 用 Cast 将 dataGridView1 的所有行转化为 List<DataGridViewRow>

    var list = dataGridView1RowsCast<DataGridViewRow>();

    // 用 First 返回第一个匹配项符合条件xCells[0]Value 等于 灭火器的 Row

    var firstmatch = listFirst(x => xCells[3]Value != null 

    && xCells[3]ValueToString() == "灭火器"); 

    //firstmatchIndex即为索引,使其高亮显示

        dataGridView1Rows[firstmatchIndex]

        DefaultCellStyleBackColor = ColorYellow;

}

二、获取所有匹配行

// 用 Cast 将 dataGridView 的所有行转化为 List<DataGridViewRow>

var list = dataGridView1RowsCast<DataGridViewRow>();

// 用 Where 返回所有匹配项

var allmatch = listWhere(x => xCells[3]Value != null && xCells[3]ValueToString() == "灭火器");

//RowIndex即为索引,使其高亮显示

foreach (var item in allmatch) {

    dataGridView1Rows[itemIndex]

    DefaultCellStyleBackColor = ColorYellow;

}

对软糖的答案满意吗,请及时采纳,谢谢了。

jquery的 length 属性可以获取包含 jQuery 对象中元素的数目,因此通过一下代码可以获取table的行数

$("table tr")length

实例演示如下

创建Html元素

<div class="box">

<span>点击按钮获取表格的行数:</span><br>

<div class="content">

<table>

        <tr><td>1</td><td>2</td><td>3</td></tr>

        <tr><td>4</td><td>5</td><td>6</td></tr>

        <tr><td>7</td><td>8</td><td>9</td></tr>

    </table>

</div>

<input type="button" value="获取表格的行数">

</div>

设置css样式

divbox{width:300px;padding:20px;margin:20px;border:4px dashed #ccc;}

divbox span{color:#999;font-style:italic;}

divcontent{width:250px;margin:10px 0;padding:20px;border:2px solid #ff6666;}

table{border-collapse:collapse;}

td{width:30px;height:30px;line-height:30px;text-align:center;border:1px solid green;}

编写jquery代码

$(function(){

$(":button")click(function() {

alert($("divcontent table tr")length);

});

})

观察效果

EditText edit = (EditTex)findViewById(Ridedittext);String str = editgetText()toString();这样str 就是EditText中你输入的值了 祝你愉快,哦

以上就是关于看见你的帖子 请教QT中QTextBrowser控件的用法 http://zhidao.baidu.com/question/291810412.html全部的内容,包括:看见你的帖子 请教QT中QTextBrowser控件的用法 http://zhidao.baidu.com/question/291810412.html、c#如何获取dataGridView中特定行的行数。 比如 资产名称=灭火器 的行数.、如何用jquery 取得table的总行数等相关内容解答,如果想了解更多相关内容,可以关注我们,你们的支持是我们更新的动力!

欢迎分享,转载请注明来源:内存溢出

原文地址:https://54852.com/web/9451616.html

(0)
打赏 微信扫一扫微信扫一扫 支付宝扫一扫支付宝扫一扫
上一篇 2023-04-28
下一篇2023-04-28

发表评论

登录后才能评论

评论列表(0条)

    保存