如何在CSharp的标签控件中显示选定的行 [英] how Do Show Selected Rows In Label Control In CSharp

查看:150
本文介绍了如何在CSharp的标签控件中显示选定的行的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

大家好

我想在csharp的Label控件中显示所选的前10条记录

例如,记录字段为:

姓名家庭电话号码

如何在10行中显示上面带有标签的记录,如下所示:

Hi All

I Want Show Selected Top 10 Record In Label Control in csharp

For Example Record Fields Are :

Name Family Phone Number

How Do Show Above Records In 10 Rows With Label Like Below :

Name1  Family1  Phone1 Number1


Name2  Family2  Phone2 Number2


...


Name10  Family10  Phone10 Number10



注意:
以上记录显示在Label和NOt DataGridView中

非常感谢



Attention :
Above Record Show In Label and NOt DataGridView

Thanks A Lot

推荐答案

你好,


例如您要显示人物实体.

Hello,


for example you want to show person entity.

var people = context.People.Select(p=>p);

people = (people.Count()>=10)? people.Top(10): people.Top(people.Count());

foreach(Person p in people)
{
   Label name = new Label();
   name.Text = p.Name;
   Label family = new Label();
   family.Text = p.Family;
   //...

   this.Controls.Add(name);
   this.Controls.Add(family);
   //...
}



上下文是您的整个数据库;如果您不知道如何拥有它,请忘记它,并使用存储context.People
的Person实体存储的集合 例如,您有一个List<Person> PeopleList;



context is your whole database; if you don''t know how to have it then forget it and use the collection that is storing the Person entity insted of context.People
For example you have a List<Person> PeopleList;

var people = (PeopleList.Count()>=10)? PeopleList.Top(10): PeopleList.Top(PeopleList.Count());
//...



也许您需要设置所有LabelLeftTop.


我已经手动编写了代码,但尚未测试,但是基础是正确的.



Maybe you need to set Left and Top of all Labels.


I''ve written the code by hand and I haven''t tested it but the base is correct.


这篇关于如何在CSharp的标签控件中显示选定的行的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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