|
Here is my code to move list items down the list.
<br />
if (!(listView1.SelectedIndices.Count == 0))<br />
if (!(listView1.SelectedIndices.Count > 1))<br />
{<br />
if (listView1.SelectedItems[listView1.SelectedIndices.Count - 1].Index != listView1.Items[listView1.Items.Count - 1].Index)<br />
{<br />
int current = listView1.SelectedItems[0].Index;<br />
ListViewItem lvi = new ListViewItem();<br />
lvi = (ListViewItem)listView1.Items[current];<br />
listView1.Items[current] = (ListViewItem)listView1.Items[current + 1].Clone();<br />
listView1.Items[current + 1] = lvi;<br />
listView1.Items[current + 1].Selected = true;<br />
}<br />
}<br />
If there are more then 4 items in the list it will move down the list no problem but "listView1.Items[current + 1].Selected = true;" will not work, it will select the wrong item after (appears to be listview1.Items[current + 3] thats being selected.
What is causing this and how do i fix it?
|
|
|
|
|
Hi,
Can anybody give an example of Virtual functions in .Net? Eventhough I searched in google, I didn't get any site that explains virtual functions in simple terms. Will be great if you could provide an example or provide an url that explains with example.
Thanks in advance.
Meeram395
|
|
|
|
|
HI consider this situation
using System;
using System.Collections.Generic;
using System.Text;
namespace @virtual
{
class Base
{
public void Display()
{
Console.WriteLine("I am from base");
}
}
class Derived : Base
{
public void Display()
{
Console.WriteLine("I am from derived");
}
}
class Program
{
static void Main(string[] args)
{
Base b = new Derived();
b.Display();
Console.Read();
}
}
}
The result will be I am from Base
If you want to dispaly the derived class method you can use virtual methods
using System;
using System.Collections.Generic;
using System.Text;
namespace @virtual
{
class Base
{
public virtual void Display()
{
Console.WriteLine("I am from base");
}
}
class Derived : Base
{
public override void Display()
{
Console.WriteLine("I am from derived");
}
}
class Program
{
static void Main(string[] args)
{
Base b = new Derived();
b.Display();
Console.Read();
}
}
}
this will give I am from Derived
Its like abstract methods, Try to learn design patterns,in which virtual methods are used
My small attempt...
|
|
|
|
|
// ClassA
class A
{
public void M()
{
Console.WriteLine("A.M() being called");
}
public virtual void N()
{
Console.WriteLine("A.N() being called");
}
}
// Class B
class B : A
{
public new void M()
{
Console.WriteLine("B.M() being called");
}
public override void N()
{
Console.WriteLine("B.N() being called");
}
}
say
A a = new B();
a.M();
a.N();
The results would be
A.M() being called
B.N() being called
|
|
|
|
|
Thank you very much for your efforts. it is very clear and simple
Meeram395
|
|
|
|
|
The two answers above give the code, but lack an explanation.
Virtual (and abstract methods) allow you to defer functionality to a derived class. So basically it allows you to write your base class and assume that anyone who ingherits from it can change the behaviour in some way.
|
|
|
|
|
Hi. I would like to create a TreeView with a rootNode( tree.Nodes.Add("root"); ), and then put there some nodes.
|
|
|
|
|
tree.ShowPlusMinus = false;
Return to innocence
|
|
|
|
|
No it's not that i want, but thanks! I want to remove "plus" only from rootNode, but childNodes of rootNode, which have "children"
must have "plus".
|
|
|
|
|
treeview.ShowRootLines = false;
|
|
|
|
|
|
Hi
We are developing Mail tool,
One of the part of this mail tool is to identify the history of mails for one particular email Id
Actually we use webdav search method, to fetch the unread mails from
exchange server and update the status as read, the fetched mails are
inserted into sqlserver table.
Our Problem is.
How to identify the thread mails,
How to differentiate the thread mails to normal mails
How to group by the thread mails
How to identify the first mail in the thread.
Regards,
Arunkumar S

|
|
|
|
|
Hi all,
I'm fairly new at C# and application development in general (I was trained as an embedded systems engineer...). Recently I've had to use C# in the development of a prototype .NET user interface. The old, unmanaged C++ version of the interface made use of a controls library which had specialised int/double text boxes which I emulated by manipulating the Textbox's KeyPress event. Because I find myself using this control in so many dialogues, I've been trying to look for a way to creating a class which inherits from the Forms.Textbox class which I can add onto the Designer from the Toolbox (I should add at this stage that I am using MS Visual Studio 2005).
Any help will be greatly appreciated
cheers!
|
|
|
|
|
You should have no problem with this - its quite straight forward.
All you need to do is create a class and derive it from the TextBox. Then you can override the OnKeyPress/OnKeyDown event(s) as necessary and do whatever work you would usually do against each instance.
Here's my simple example to get you started... it just MessageBox's every character you type.
public class AnnoyingTextBox : TextBox<br />
{<br />
<br />
protected override void OnKeyPress(KeyPressEventArgs e)<br />
{<br />
MessageBox.Show(e.KeyChar.ToString());<br />
base.OnKeyPress(e);<br />
}<br />
}
|
|
|
|
|
Thanks for that...
I'll get cracking straight away on creating the class derived from Textbox, but when I am done how do I add this to the list of controls (the 'Toolbox' in Visual Studio 2005) where one can drag and drop controls onto the WYSIWYG designer? It's just that it's much easier to be able to do this when designing a dialogue rather than to manually type in the numbers and *hope* you get it in the right place...
cheers!
|
|
|
|
|
I found a pretty good article describing what has to be done to extend MS Visual Studio's toolbox: http://symbian.sys-con.com/read/113332.htm
cheers!
|
|
|
|
|
Hi All
I create an FTP Application to download data from ftp.I want to calculate estimated download time but i don't know "how to get estimated download time". If any one know please help me
thanx & regards
SMK
|
|
|
|
|
You estimate it based on how much you still need to download, and how much you're getting per second.
Christian Graus - Microsoft MVP - C++
Metal Musings - Rex and my new metal blog
"I am working on a project that will convert a FORTRAN code to corresponding C++ code.I am not aware of FORTRAN syntax" ( spotted in the C++/CLI forum )
|
|
|
|
|
Thanx for reply, but i got the solution in c#
Thanx & Regards
SMK
|
|
|
|
|
Hi All,
I'm implementing drag/drop in my windows forms 2.0 / c# application.
In my control's MouseDown event handler, i'm calling DoDragDrop appropriately. But, the call to DoDragDrop seems to prevent other mouse events (MouseClick, DoubleClick, etc) from firing.
Is there a way round this? I need to be able to distinguish between a mouse-down drag starting event and a double click.
Thanks
Jon
|
|
|
|
|
I was doing something similar to what you are doing using DragDrop for a TreeView control and trying to use Click, Double Click, etc. and I found no way around it.
Hope this helps
Mike
Theres light at the end of the tunnel. Lord I hope it ain't no train!
|
|
|
|
|
Hi Mike,
Thanks for your post. If you're interested, i found the solution.
You're not supposed to call DoDragDrop from the MouseDown event. Instead, you should use the mousemove event, and call DoDragDrop where the L button is down and the mouse has moved outside of the rectangle centered around the point that the mousedown happened, of size SystemInformation.DragSize.
This example http://msdn2.microsoft.com/en-us/library/system.windows.forms.control.dodragdrop(vs.71).aspx[^] demonstrates the method perfectly.
I hope that helps you.
Jon
|
|
|
|
|
Jon,
My first thought was ahhh so thats how to do it and then it went to duhhhhh!
Thanks for the response I'll definatly use that.
Mike
Theres light at the end of the tunnel. Lord I hope it ain't no train!
|
|
|
|
|
Is there any possibility to enable scripting in internetexplorer using c#
Thanks In Advance
|
|
|
|
|
You mean via ASP.NET, or when you have a client app running on the target machine ? If the latter, then perhaps, but I doubt it. If the former, then, no way. Your C# code is never going to run on the client.
Christian Graus - Microsoft MVP - C++
Metal Musings - Rex and my new metal blog
"I am working on a project that will convert a FORTRAN code to corresponding C++ code.I am not aware of FORTRAN syntax" ( spotted in the C++/CLI forum )
|
|
|
|