|
Hello friends,
I am looked for an answer all over the net and couldnt find:
I have a datagridview (VS 2005) with VirtualMode set to true. its DataSource is a DataTable.
I have some data bound columns (not auto generated), and I add one unbound column.
I tried to sort this unbound column in without any succeed:
I tried to call the sort function of the dgv but I get an error that this is not supported. (to sort by unbound column).
I also tried to catch the dgv SortCompare event and to make the sort by myself, but i understand that this event doesnt fired in VirtualMode.
Please help me...
thanks a lot
Tomer
Chupa Chupa
|
|
|
|
|
i need to know what type of object , and retrieve it from textbox.text
i mean , text = "Test" is string object
text = 123 is int object
Like
if (Textbox.Text is int?????? )
debug.write ("int")
else
debug.write ("String")
123
|
|
|
|
|
If you are obtaining the data from a textbox it will always be a string until you convert to something else.
int x;
if( int.TryParse(TextBox.Text, out x) )
debug.write("int");
only two letters away from being an asset
|
|
|
|
|
if you expect some type you can try converting or parsing Text property of the textbox..
example:
bool success = false;
int outVal;
success = int.TryParse(Textbox.Text, out outVal);
if(success)return outVal;
and so on with other types..
life is study!!!
|
|
|
|
|
Good afternoon, I'm investigating about the ScrollBar and I have found some info that could be interesting, using a VisualStyleRenderer
VisualStyleRenderer render = new VisualStyleRenderer(VisualStyleElement.ScrollBar.ThumbButtonVertical.Normal);
Rectangle thum_pos = render.GetBackgroundExtent(e.Graphics, vScrollBar1.Bounds);
Does anyone know how to get the Elements Position of a control using the VisualStyles and overpaint them?...
All info and links will be welcome.
Thanks everyone
|
|
|
|
|
Hello,
I am new to C# programming (day 1). I have created a list view object dynamically, and added 1000 items to it. Now I want to copy these objects to another list view, which wasn't dynamically created. But I do not see the contents to get coiped. The following is the corresponding code.
ListView lv = new ListView();
for (int i = 0; i < 1000; i++)
{
lv.Items.Add(new ListViewItem("Hi there"));
}
listView1 = lv; <font color=green>
Nobody can give you wiser advice than yourself. - Cicero
|
|
|
|
|
you might need to call listView1.Refresh() after you assign lv to it
Don't be overcome by evil, but overcome evil with good
|
|
|
|
|
Actually, I tried that before posting it. That doesn't help.
Nobody can give you wiser advice than yourself. - Cicero
|
|
|
|
|
I thought that woulda worked (that or "Update()"). but it doesn't. When i debugged it i did see it get copied over though.
the only other thing that i can think of is something like this
ListView lv = new ListView();
lv.Items.Add(new ListViewItem("Hello"));
foreach (ListViewItem items in lv.Items)
{
ListViewItem lvItem = (ListViewItem)items.Clone();
listView1.Items.Add(lvItem);
}
Don't be overcome by evil, but overcome evil with good
|
|
|
|
|
Thanks, that works! But loading items in the ListView becomes real slow if the no. of items become huge.
teejayem wrote: When i debugged it i did see it get copied over though.
If it gets copied over, is there any way I could refresh the state of it somehow, so that it reflects it in the UI too?
Nobody can give you wiser advice than yourself. - Cicero
|
|
|
|
|
Hi,
adding them one by one causes a recalculation of the layout every time.
There are two ways to avoid this speed trap:
- add a range of items
- suspend and resume layout
See the corresponding ListView methods.
|
|
|
|
|
Luc Pattyn wrote: There are two ways to avoid this speed trap:
- add a range of items
- suspend and resume layout
Thank you very much Luc Pattyn. I will look into it. The speed trap was the actual problem.
Nobody can give you wiser advice than yourself. - Cicero
|
|
|
|
|
Personally what i would have done is create a dataset object and go through each row of the dataset and add items to the listview if you'd like a snippet of that please let me know
Don't be overcome by evil, but overcome evil with good
|
|
|
|
|
Please give me a snippet. That would help me.
Nobody can give you wiser advice than yourself. - Cicero
|
|
|
|
|
DataSet ds = new DataSet();
ds.Tables.Add("Table 1");
ds.Tables[0].Columns.Add("Column 1");
ds.Tables[0].Rows.Add("Hello");
ds.Tables[0].Rows.Add("World");
foreach (DataRow row in ds.Tables[0].Rows)
listView1.Items.Add(row.ItemArray[0].ToString());
Hope this helps
Don't be overcome by evil, but overcome evil with good
|
|
|
|
|
What is that your trying to do? Why do you want to add it to one listview and again add it to another listview? You can use a listviewitem and add it to both the listview's if that is what your trying to do.
|
|
|
|
|
Tarakeshwar Reddy wrote: Why do you want to add it to one listview and again add it to another listview?
One is in the memory, and another is in the UI.
Tarakeshwar Reddy wrote: You can use a listviewitem and add it to both the listview's if that is what your trying to do.
No, I've added some items to a listview in the memory, and then I want all these items to be added to the one in the UI.
Nobody can give you wiser advice than yourself. - Cicero
|
|
|
|
|
brahmma wrote: No, I've added some items to a listview in the memory, and then I want all these items to be added to the one in the UI.
But why would you want to do that? Is there a specific reason you want to have the items in the memory? You will have to add 1000 items in the listview object in memory and again re-add 1000 items to the listview in the UI, thats almost like adding 2000 items and that would surely slow down the app.
|
|
|
|
|
Doing stuff in the memory is certainly faster. And I was testing with it and trying to find out if there is a function that would update the status of a control. (UpdateData() , in MFC does that in both directions, between a control and a member variable).
Tarakeshwar Reddy wrote: You will have to add 1000 items in the listview object in memory and again re-add 1000 items to the listview in the UI, thats almost like adding 2000 items and that would surely slow down the app.
You see, I was trying to find out if I could copy a listview object in memory to another.
Nobody can give you wiser advice than yourself. - Cicero
|
|
|
|
|
brahmma wrote: You see, I was trying to find out if I could copy a listview object in memory to another.
Yeah I did get that, but I am not sure if you can do that. You have an option to do an AddRange which would add a listview[], but I am not sure if that would be of any help to you either.
|
|
|
|
|
Hmm... Looks like I've done a bad start with C#.
Nobody can give you wiser advice than yourself. - Cicero
|
|
|
|
|
brahmma wrote: One is in the memory, and another is in the UI.
so you have to add it twice. sure it will slow down the application.
Regards,
Satips.
|
|
|
|
|
I think you did not get it right. I wanted to know if I could copy an listview object (along with its status) to another listview object, one being in the memory and another one being in the UI.
Nobody can give you wiser advice than yourself. - Cicero
|
|
|
|
|
oh.
Regards,
Satips.
|
|
|
|
|
brahmma wrote: listView1 = lv; //Can I equate it like this?
That line does not copy the contents, it just makes listView1 refer to whatever lv was referring to. After executing that statement, both listView1 and lv refer to the same object.
Taking a guess at why you don't see the list items in the UI, you probably added listView1 to the form's Control collection i.e
form.Controls.Add(listView1);
Making listView1 refer to another object by writing listView1 = lv will not change the ListView object in the Controls collection. You can see why if you think of listView1 and lv as pointers to ListView instances (which they are).
Hope this helps.
|
|
|
|