|
Treeview on left and listview on right with a splitter bar in between?
What else are you looking for?
Cheers,
Simon
"Sign up for a chance to be among the first to experience the wrath of the gods.", Microsoft's home page (24/06/2002)
|
|
|
|
|
A ready to use treeview with directory tree and icons
A ready to use listview with directory file infos and icons
just a ready to use control wich acts like the windows explorer, but as controls in my form.
Got an idea ?
Thanks
|
|
|
|
|
This event is being fired even when I change the selected index in the combo box in my code, by doing this for example:
comboBox.SelectedItem = "abc";
But I want an event to fire only when the user changes the selection, by using the mouse or keyboard etc. Is this possible?
|
|
|
|
|
Its not possible; but you can work around it. Create a private variable, before you alter the index set it to true; after you set the index set it to false.
In your event handler check that variable to see if it is true; if it is then you can be pretty sure that it was your program that changed the selection and not the user.
HTH,
James
"Java is free - and worth every penny." - Christian Graus
|
|
|
|
|
Thanks, thats a nice way around it and I was using that method for a while when I came across another event in the ComboBox - SelectionChangeCommitted - and this one does seem to only trigger when the user makes a selection in the list box part of the combo. Just FYI for anyone out there.
|
|
|
|
|
I call this function to remove the last item in a listview in details view. The problem is that the control is on a tab page, and if i call this function before the control has been viewed(ie. before the tab page with this control is shown), this function fails with the inner exception of message "Object reference not set to an instance of an object", and, the regular exception of "unable to create handle". This only happens if the control is not viewed first. Can someone help me out here.
public void RemoveLastItem()
{
int index = Items.Count;
try {
Items.RemoveAt(index-1);
}
catch(OutOfMemoryException e){ // Error is caught here!! Why ????
#if DEBUG
MessageBox.Show(e.InnerException.Message);
#endif
}
catch(NullReferenceException e){
#if DEBUG
MessageBox.Show(e.Message);
#endif
}
}
|
|
|
|
|
Brandon,
have you tried instantiating the listView control. if your in the same class you should be able to use "this". if your in another class you should be able to get to the listView by creating a new instance of that class if you haven't already and get to the listView that way.
MyClass cl = new MyClass()
cl.MylistView....
when i add: here parameter is an ArrayList and this code sits in a foreach
ListViewItem item = new ListViewItem(parameter);
item.SubItems.Add("");
this.listView_Parameters.Items.Add(item);
i'd expect Remove() would be the opposite.
hope i didn't state the obvious
Orion
|
|
|
|
|
Yes you have stated the obvious;P Remember I said this only occures when the tabpage that hold the listview control isnt first viewed. The listview is created along with that tabpage in the forms constructor so it is instantiated. Im thinking somehow that the items in the view control arent actually created until they are needed(ie. when the control is viewed). But, the truth is im not sure what is going on.
|
|
|
|
|
What happens if you call CreateControl() on the ListView in the constructor; this forces the control to create itself instead of delaying until it feels it is best to do so (ie when you view that tab for the first time).
James
"Java is free - and worth every penny." - Christian Graus
|
|
|
|
|
|
hello,
i'm trying to do 2 things with this control.
the first is add a value to a sub-column of a row(or officially stated, the sub item to the item). the catch is, i can add the item to the row if its Selected. such as:
listView.Items[listView.SelectedItems[0].Index].SubItems[1].Text = this.textBox_Value.Text;
if i try to add the value without a row being selected it crashes the control. if i try:
item.SubItems.Add(this.textBox_Value.Text);
this.listView_Parameters.Items[0] = items;
it just adds it to the second column of a new row.
so how do i add a value to a particular row/sub-column without selecting that row?
the second, i've also been trying to show a row as being Selected with the blue line. ideally i'd like to put a value in the control and show it as if its been selected.
any advice would be greatly appreciated.
i'm probably missing something obvious...
thank you,
Orion
|
|
|
|
|
look at your code. If you use SelectedItems property to get an index value for your listview, and no item is selected there wont be a value in SelectedItems[0], thats why it crashes.
// Add a new item and at subcolumn
int index = Items.Count;
ListViewItem item = new ListViewItem("Column Text,index)
item.SubItems.Add("Subcolumn Text");
Items.Add(item);
// Add only a subitem to an existing item
listView.Items[index].SubItems.Add("subcolumn Text");
you can show a blue line by first adding the item to the row then use the controls SelectedItem property to select the index of the new item. You might also want to make sure that fullrowselect is set to true.
Brandon Parker
|
|
|
|
|
thanks Brandon,
actually a few minutes after i posted it i did get the first part. i did it a little different though.
listView.Items[0].SubItems[1].Text = this.textBox_Value.Text;
as for showing the blue line, i want to show it before any sub item has been added. to let the user know the first row has been auto selected. i've got the FullRowSelect prop set to true, no problem.
if i do
this.listview.SelectedItems[0] = true;//it complains
Orion
|
|
|
|
|
try this instead. I havent tried it so im not sure it will work,so let me know. Also remember, if you use the SelectedItems Property and no item is selected then it will be null. so it will complain.
this.listView.Items[0].Selected = true;
|
|
|
|
|
it sort of works, but now the value i'm adding to the sub item/second column doesn't go in...
back to the drawing board
and thanks
Orion
|
|
|
|
|
ADO.NET does not support server cursor.Then when you need it do you think does it worth to use C# and import ADO,Or you use VC and ADO there?
Mazy
"If I go crazy then will you still
Call me Superman
If I’m alive and well, will you be
There holding my hand
I’ll keep you by my side with
My superhuman might
Kryptonite"Kryptonite-3 Doors Down
|
|
|
|
|
I don't see why a DataReader isn't a server-side cursor.
Anyone know why?
Cheers,
Simon
"Sign up for a chance to be among the first to experience the wrath of the gods.", Microsoft's home page (24/06/2002)
|
|
|
|
|
Hi
I have looked at LiveCode.NET sample, but that is GREEK to me. Perhaps someone can show or help me with an easier way.
I want to be able to load assembly at runtime. This assembly will need to reference a single object from the main program. The main program should only have access to a Load/Initialize and an Unload method in the assembly.
Can someone please help me or point me into the right direction?
Thanks in advance.
READ MSDN
|
|
|
|
|
There is an article on MSDN written by Eric Gunnerson where he develops a plug-in system; his is more advanced but you can see how he does it.
HTH,
James
"Java is free - and worth every penny." - Christian Graus
|
|
|
|
|
Thanx will have a look
UPDATE: Had a quick look (still greek ) and will read some more. All my "plugin" does (well will do) is hook onto one object( Connection Class) and responds to events. He talks about going the interface way (I only need to call a single known method) , but he then opts for the delegate way. I presume the interface way is the one I should follow, but how???
|
|
|
|
|
I use interfaces in my article "Using reflection to extend .NET programs", which should give you an idea how you could alter Eric's code to use interfaces.
HTH,
James
"Java is free - and worth every penny." - Christian Graus
|
|
|
|
|
Thx
READ MSDN
|
|
|
|
|
Hi JTJ
Shot JTJ. It IS exactly what I meant "an easy way". The other article just confused me, but could prove helpful at a later stage. Just one more question. If I have an method e.g. Init(object sender) specified in the interface, does "sender" get passed by value or by reference? Or should I maybe define it as e.g. Init(ref object sender)?
OK, I lied just one more now. If I register eventlisteners on "sender" , do I need to deregister them when I "unload" the assembly or will they get "destroyed" automatically? And how does the "assembly" get disposed of? When the interface goes out of scope?
Thanx again
READ MSDN
|
|
|
|
|
leppie wrote:
If I have an method e.g. Init(object sender) specified in the interface, does "sender" get passed by value or by reference?
In this particular case, it will be passed by reference.
Everything is always passed by reference unless the type inherits from ValueType somewhere in the hierarchy. As a general rule if its a class it will be passed by reference; if it is a struct or a intrisnic type (int, float, bool) it will be passed by value. Though string is an intrisnic type it violates this rule by being a class; so it is passed by reference and not by value.
leppie wrote:
Or should I maybe define it as e.g. Init(ref object sender)?
Doing this means that you can change the value that the variable references; so that it is referencing something different. Generally you would want to leave the original variable referencing the same thing.
leppie wrote:
do I need to deregister them when I "unload" the assembly or will they get "destroyed" automatically?
I would unregister them just to be safe When dealing with finalizers you have no idea in what order or when things will happen. Unregistering them yourself would guarantee that it gets done.
leppie wrote:
And how does the "assembly" get disposed of? When the interface goes out of scope?
This is where Eric's article is superior to mine, and why I referred you to his instead of mine in the first place
Once an assembly is loaded into an AppDomain with the Assembly.Load* methods it stays there until the AppDomain is unloaded. The problem is that in my article all assemblies are loaded into the default AppDomain created when you execute a .NET program. So the only way to unload the assembly is to quit the program.
HTH,
James
"Java is free - and worth every penny." - Christian Graus
|
|
|
|
|
Many thanx again James, perhaps you should change HTH to TWH (this will help)
READ MSDN
|
|
|
|