PDA

View Full Version : کامپوننت ListView دارای خاصیت Wrap



MasoudAdmin
پنج شنبه 11 مهر 1398, 07:55 صبح
با سلام به همه
آیا به غیر از کامپوننت های معروفی مثل تلریک و غیره، کامپوننت ListView وجود دارد که بتوان برای ردیف ها خاصیت Wrap تعریف کرد تا اگر دیتایی زیاد بود با حالت Wrap همه رو نشون بده.
ممنون میشم اگه راهنمایی بکنید تا اگر کامپوننتی دارید در دسترس قرار بدید تا بتوانم ازش استفاده کنم.

ASHKANLAEI
پنج شنبه 11 مهر 1398, 08:01 صبح
مگه خود listview حالت wrap نداره؟؟

MasoudAdmin
پنج شنبه 11 مهر 1398, 15:39 عصر
خیر متاسفانه. لااقل من در property ها ندیدم. اگر این قابلیت داره راهنمایی کنید.
ممنون

ASHKANLAEI
پنج شنبه 11 مهر 1398, 16:00 عصر
یکی از کامپوننت ها، objectlistview (http://objectlistview.sourceforge.net/cs/index.html) هست که میتونید استفاده کنید

MasoudAdmin
جمعه 12 مهر 1398, 23:41 عصر
متاسفانه اینم که اضافه کردم و توی فرمم گذاشتم، حتی با اینکه هنوز کدی هم نوشته نشده و فقط این آبجکت رو در فرم گذاشتم برنامه که اجرا میشه خطا میده. برنامه هم به دات نت 4 تغییر دادم ولی باز هم خطا داد.:ناراحت::افسرده:

ASHKANLAEI
شنبه 13 مهر 1398, 06:27 صبح
چه اروری میده دوست عزیز؟

MasoudAdmin
شنبه 13 مهر 1398, 20:31 عصر
خطاش مربوط به ورژن دات نت فریم ورک هست. باید ورژهای پایین تر از 4 رو انتخاب کنم، که من برنامم جوریه که نمی تونم با دات نت کمتر از نسخه 4 کار کنم.:افسرده:
راه حل دیگه ای ممکنه باشه؟

ASHKANLAEI
یک شنبه 14 مهر 1398, 05:12 صبح
http://www.componentowl.com/documentation/better-listview/data/chapter-multi-line.html
(یک کامپوننت دیگه)

اگه کار نکرد؛
این رو توی stack overflow پیدا کردم:
class WordWrapListView : ListView
{
private const int LVM_FIRST = 0x1000;
private const int LVM_INSERTITEMA = (WordWrapListView.LVM_FIRST + 7);
private const int LVM_INSERTITEMW = (WordWrapListView.LVM_FIRST + 77);

private Graphics graphics;

public WordWrapListView()
{
this.graphics = this.CreateGraphics();
base.View = View.Details;

this.AutoSizeRowHeight = true;

}

//overriding WndProc because there are no item added events
protected override void WndProc(ref Message m)
{
switch (m.Msg)
{
// Detect item insert and adjust the row size if necessary based on the text
// add in LVM_DELETEITEM and LVM_DELETEALLITEMS and reset this.rowHeight if you want to reduce the row height on remove
case WordWrapListView.LVM_INSERTITEMA:
case WordWrapListView.LVM_INSERTITEMW:
{
ListViewItem lvi = this.Items[this.Items.Count - 1];

for (int i = 0; i< lvi.SubItems.Count; ++i)
{
ListViewItem.ListViewSubItem lvsi = lvi.SubItems[i];

string text = lvsi.Text;

int tmpHeight = 0;
int maxWidth = this.Columns[i].Width;

SizeF stringSize = this.graphics.MeasureString(text, this.Font);

if (stringSize.Width > 0)
{
tmpHeight = (int)Math.Ceiling((stringSize.Width / maxWidth) * stringSize.Height);

if (tmpHeight > this.rowHeight)
{
this.RowHeight = tmpHeight;
}
}
}
}
break;

default:
break;
}
base.WndProc(ref m);
}

private void updateRowHeight()
{
//small image list hack
ImageList imgList = new ImageList();
imgList.ImageSize = new Size(this.rowHeight, this.rowHeight);
this.SmallImageList = imgList;
}

[System.ComponentModel.DefaultValue(true)]
public bool AutoSizeRowHeight { get; set; }

private int rowHeight;
public int RowHeight
{
get
{
return this.rowHeight;
}
private set
{
//Remove value > this.rowHeight if you ever want to scale down the height on remove item
if (value > this.rowHeight && this.AutoSizeRowHeight)
{
this.rowHeight = value;
this.updateRowHeight();
}
}
}

// only allow details view
[Browsable(false), Bindable(false), DesignerSerializationVisibility(DesignerSerializat ionVisibility.Hidden), EditorBrowsable(EditorBrowsableState.Never)]
public new View View
{
get
{
return base.View;
}
set
{

}
}

}
ببینید کار میکنه؟

MasoudAdmin
یک شنبه 14 مهر 1398, 10:51 صبح
با سلام و سپاس.
متاسفانه این کامپوننت هم نسخه trial هست و هر بار که برنامه اجرا میشه، یک صفحه اول برنامه میاد که باید خریداری بشه و یک کلید Continue داره که اونم وقتی زده بشه با حالت Trial میاد بالا.