نقل قول: مرتب کردن محتوای listbox
با این دستور میشه مرتط کرد
listbox1.Sorted = true;
برای پیدا کردن یک فیلد خاص هم یه تابع برای جستجو بنویس البته اگه منظورتون همینه
نقل قول: مرتب کردن محتوای listbox
دوستان تا حالا خیلی روش کار کردم ولی به نتیجه ای نرسیدم باید چکار کنم تا بتوانم این کار را انجام دهم؟:متفکر:
نقل قول: مرتب کردن محتوای listbox
والا این تابع واسه سرچ:
private void FindAllOfMyString(string searchString)
{
ListBox1.SelectionMode = SelectionMode.MultiExtended;
int x = -1;
if (searchString.Length != 0)
{
do
{
x = ListBox1.FindString(searchString, x);
if (x != -1)
{
if (ListBox1.SelectedIndices.Count > 0)
{
if (x == ListBox1.SelectedIndices[0])
return;
}
ListBox1.SetSelected(x, true);
}
} while (x != -1);
}
}
تو رویداد keyup بنویس اینطوری:
ListBox1.SelectedIndex = -1;
FindAllOfMyString(textBox1.Text);
نقل قول: مرتب کردن محتوای listbox
با سلام.
listBox1.DataSource = listBox1.Items.Cast<string>().Where(item => item.StartsWith("b")).ToArray();
نقل قول: مرتب کردن محتوای listbox
سلام می خواستم ایتم های موجود در یک لیست باکس را درون یک آرایه دخیره کنم روش های زیادی رفتم ولی هیچ کدام جواب نداد باید چگونه این کار را انجام دهم خیلی لازم دارم باید تا فردا آماده اش کنم لطفا جواب دهید
نقل قول: مرتب کردن محتوای listbox
دوستان یعنی هیچ روشی وجود ندارد
نقل قول: مرتب کردن محتوای listbox
اون روش هایی که رفتین رو توضیح بدین و کداش رو بذارین تا بفهمیم مشکل از کجاس
نقل قول: مرتب کردن محتوای listbox
کد HTML:
int count=(listBox1.Items.Count)-1;
string[] str = new string[count];
for (int i = 0; i < count; i++)
{
str[i] = listBox1.SelectedItems.ToString();
}
کد HTML:
int count=(listBox1.Items.Count)-1;
string[] str = new string[count];
for (int i = 0; i < count; i++)
{
listBox1.Items.CopyTo(str, count);
}
خوب اینم کداش حالا میشه کمک کنید؟
نقل قول: مرتب کردن محتوای listbox
int[] a = listBox1.Items.Cast<int>().ToArray();
اینو تست کن مثلا اینجا محتویات عدد هستند!!!
و اینجا رشته
string[] a = listBox1.Items.Cast<string>().ToArray();
و اینم برای کد خودتون و فریم ورک 2
string [] s= new string
[listBox1.Items.Count];
for (int i = 0; i < listBox1.Items.Count; i++)
{
s[i] = listBox1.Items[i].ToString();
}
نقل قول: مرتب کردن محتوای listbox
نقل قول:
نوشته شده توسط
nimaakbari
کد HTML:
int count=(listBox1.Items.Count)-1;
string[] str = new string[count];
for (int i = 0; i < count; i++)
{
str[i] = listBox1.SelectedItems.ToString();
}
کد HTML:
int count=(listBox1.Items.Count)-1;
string[] str = new string[count];
for (int i = 0; i < count; i++)
{
listBox1.Items.CopyTo(str, count);
}
خوب اینم کداش حالا میشه کمک کنید؟
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using System.Collections;
namespace this_show
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
listBox1.Sorted = true;
listBox1.SelectionMode = SelectionMode.MultiExtended;
}
private void Form1_Load(object sender, EventArgs e)
{
}
private void Form1_FormClosing(object sender, FormClosingEventArgs e)
{
}
private void button1_Click(object sender, EventArgs e)
{
ArrayList alCust = new ArrayList();
int c = listBox1.SelectedIndices.Count;
foreach (object selectedItem in this.listBox1.SelectedItems)
{
alCust.Add(selectedItem);
}
listBox2.DataSource = alCust;
}
}
}
نقل قول: مرتب کردن محتوای listbox
با تشکر کدی که گفته بودید کار می کنه