|
Thanks for the reply.
Listview does not contain DataSource and DataBind.
|
|
|
|
|
Sorry, I never thought of that, but you could still get the array from the view.. but anyhow you got the the sort method from the other response..
-----
|
|
|
|
|
I have a class that I use for this. I got the basics from a web page that I can't locate to give credit but I've ammended it quite a lot. There's probably quite a few bits 'wrong' but it works.
It uses the Tag property of each column to set the data type as String, Numeric or Date (sent as a string ie "Numeric".
If the column being sorted has two peices of identical data, it will sort recursively through any further SubItems using their Tag to determine data type.
using System;
using System.Collections;
using System.Windows.Forms;
namespace ListViewHandling
{
class Sorter : IComparer
{
private int _SortColumn;
private SortOrder _SortOrder;
private string _SortType;
public Sorter(int SortColumn, string SortType, SortOrder SortOrder)
{
_SortColumn = SortColumn;
_SortOrder = SortOrder;
_SortType = SortType;
}
public int Compare(object x, object y)
{
int Result = 0;
ListViewItem ItemX;
ListViewItem ItemY;
ItemX = (ListViewItem)x;
ItemY = (ListViewItem)y;
switch (_SortColumn)
{
case 0:
switch (_SortType)
{
case "Numeric":
Result = decimal.Compare(Convert.ToDecimal(ItemX.Text), Convert.ToDecimal(ItemY.Text));
break;
case "Date":
Result = DateTime.Compare(DateTime.Parse(ItemX.Text), DateTime.Parse(ItemY.Text));
break;
default:
Result = ItemX.Text.CompareTo(ItemY.Text);
break;
}
break;
default:
switch (_SortType)
{
case "Numeric":
Result = decimal.Compare(Convert.ToDecimal(ItemX.SubItems[_SortColumn].Text), Convert.ToDecimal(ItemY.SubItems[_SortColumn].Text));
break;
case "Date":
Result = DateTime.Compare(DateTime.Parse(ItemX.SubItems[_SortColumn].Text), DateTime.Parse(ItemY.SubItems[_SortColumn].Text));
break;
default:
Result = ItemX.SubItems[_SortColumn].Text.CompareTo(ItemY.SubItems[_SortColumn].Text);
break;
}
break;
}
if (Result == 0 && (ItemX.SubItems.Count - 1) > _SortColumn)
{
for (int i = _SortColumn + 1; i < ItemX.SubItems.Count; i++)
{
switch ((string)ItemX.SubItems[i].Tag)
{
case "Numeric":
Result = decimal.Compare(Convert.ToDecimal(ItemX.SubItems[i].Text), Convert.ToDecimal(ItemY.SubItems[i].Text));
break;
case "Date":
Result = DateTime.Compare(DateTime.Parse(ItemX.SubItems[i].Text), DateTime.Parse(ItemY.SubItems[i].Text));
break;
default:
Result = ItemX.SubItems[i].Text.CompareTo(ItemY.SubItems[i].Text);
break;
}
if (Result != 0) { break; }
}
}
if (_SortOrder == SortOrder.Descending)
{
Result = -Result;
}
return Result;
}
}
}
I fire it from the ColumnClick event but you could easily alter it
public Form1()
{
InitializeComponent();
listView1.ColumnClick += new ColumnClickEventHandler(listView1_ColumnClick);
}
void listView1_ColumnClick(object sender, ColumnClickEventArgs e)
{
listView1.ListViewItemSorter = new ListViewHandling.Sorter(e.Column, (string)listView1.Columns[e.Column].Tag, SortOrder.Ascending);
}
|
|
|
|
|
Thank You, It worked!
I have to force the tag though before sorting it.
ListView.Colums[1].Tag = "Numeric";
|
|
|
|
|
You're welcome.
Ian Uy wrote: I have to force the tag though before sorting it.
Alter the switch block so the default is "Numeric" instead of "String".
|
|
|
|
|
hi
i wrote a simple .net 2 application with csharp and i want to execute it from another client(s) on the network, but when i click on it, the microsoft error has shown me(send report,dont sent) without any useful error message.
i add this code to my AssemblyInfo :
[assembly: PermissionSet(SecurityAction.RequestMinimum, Name="FullTrust")]
but so that error shown me, where does my problem and how to solve that ?
thanks
|
|
|
|
|
A possible security related problem.
Try moving your executable on the desktop.
|
|
|
|
|
Any managed code running from an untrusted source (i.e.: any network share) runs in a restricted sandbox. Go to MSDN and search for "Code Access Security". You've got a bunch of reading to do...
|
|
|
|
|
i don't want to code access security, i want to run my exe file from network.
|
|
|
|
|
You might want to take a look at what has been suggested - it's been pointed out to you for a reason, i.e. you really need to learn how to do this if you want to break out of the Sandbox. Dave IS a MVP for a reason you know.
Deja View - the feeling that you've seen this post before.
|
|
|
|
|
hdv212 wrote: i don't want to code access security
Well, understanding CAS is a requirement when dealing with managed code, especially in running from untrusted sources. It's not an option. The only reason why all your code to this point works is because of the default security setup under the .NET Framework. Now that you've ventured outside the defaults, you've having problems. You're either going to read up on CAS, or you're going to be stuck writing simple Windows Forms app that have to be run from a local drive.
In order to "run my exe file from network", you must understand CAS. This is not optional.
|
|
|
|
|
ok, thanks.
my problem was solved, but is that any way to perform this operation by code ?
my another question :
if my app use com dll or ocx (non dot net), even above solution was not solved problem and how to run it in network ?
many thanks
|
|
|
|
|
hdv212 wrote: but is that any way to perform this operation by code ?
No, there isn't. Can you, as a normal User, give yourself PowerUser permissions?? Of course not. Managed code has the same restrictions. It cannot give itself permissions greater than that of the security context it's running in.
hdv212 wrote: my another question :
if my app use com dll or ocx (non dot net), even above solution was not solved problem and how to run it in network ?
many thanks
There was a reason why I suggested you read up on Code Access Security. If you want the answers to these questions, you MUST understand how Code Access Security works. If not, you're groping around in the dark hoping to find something that works for you in this particular instance. God help you if if breaks, 'cause if you don't understand why it broke, you're not going to be able to fix it. That's what the documentation is for and why I told you to read it.
|
|
|
|
|
Dave Kreskowiak wrote: you MUST understand
your being a little melodramatic aren't you? I mean Visual Basic is all about developing software without understanding how anything works, right?
|
|
|
|
|
led mike wrote: I mean Visual Basic is all about developing software without understanding how anything works, right?
That's the general perception, isn't it? However, if you really want to write code, in ANY language, you have to understand how stuff works, afterall, it's just as easy to write crap code in C#! At least in C++, you stand a better chance of crap code just not compiling...
|
|
|
|
|
Dave Kreskowiak wrote: you have to understand how stuff works
Stop saying that! It's supposed to be a secret.
|
|
|
|
|
Hello,
I have a little problem with the creation of a WORD document with C# and Visual .NET.
The aim is to write down some chemical structures.
I read the name plus structure information from the database and then use
a for-loop to
___write a 1x1 - table for the structure-name (I want it to be in a frame)
___move down a line,
___type a paragraph and then
___paste the structure,
___followed by some more text/paragraphs
for each structure.
When I check it with the debugging function, all is as desired, but when I don't,
the first structure is as desired (name in a frame; structure; text)
but then I have the next frame/ table-cell, containing:
___name
___structure
___text
___name in a frame
___structure
___text
___next frame containing
______name
______structure
______text
______next frame containing
_________name
_________structure
_________text
_________next frame containing
____________name
____________structure
____________text
____________...
Does anybody have a clue what happened or how I can prevent this behaviour ?
Best regards and thanks !
Dirk
|
|
|
|
|
Well, after having several troubles getting a C# app working out of a
Firefox plug-in ( see here[^] ), i finally managed to connect my
C# code, compiled as .dll to a C++ Firefox plugin .dll
Right now, i'm able to fire my C# app out of the browser window, calling my
classes within the FF plugin dll. [ It'll open up a separate form. ]
What lacks now is to have my app being painted DIRECTLY onto the plugin space,
the space reserved for the plugin in the website displaying it, that is.
The plugin gives some handles for that:
NPBool nsPluginInstance::init(NPWindow* aWindow)<br />
{<br />
if(aWindow == NULL)<br />
return FALSE;<br />
<br />
mhWnd = (HWND)aWindow->window;<br />
if(mhWnd == NULL)<br />
return FALSE;<br />
<br />
lpOldProc = SubclassWindow(mhWnd, (WNDPROC)PluginWinProc);<br />
<br />
SetWindowLong(mhWnd, GWL_USERDATA, (LONG)this);<br />
<br />
(...)<br />
Question now is:
- I do have my app functionality sitting on a UserComponent class, also could
pin it onto some form.
- How to paint that form [ UserComponent ] INTO the plugin space ?
- Also, as it isn't possible to create global instances of managed ( C# )
classes in unmanaged ( C++ ) context, how can i have my app running
simultaneously to the plugin ? [ I wondered, if it would be possible and
appropriate to run the C# in an own thread, then grabbing graphics
whenever needed and displaying / painting it in the plugin space ... ]
Hope you can figure out what i'm trying to do.
Any help is highly appreciated.
|
|
|
|
|
Could you get the DC for the window using GetDC from Win API, then get the DC for your UserComponent (through the graphics object), and finally use BitBlt to copy the image from your UserComponent class to your target area?
SomeMethod(Graphics yourUserControlGraphicsObject) {
Rectangle mRect = new Rectangle();
IntPtr trgDC = Win32.GetDC(mhWnd);
Win32.GetClientRect(mhWnd, out mRect);
IntPtr srcDC = yourUserControlGraphicsObject.GetHdc();
Win32.BitBlt(trgDC, 0, 0, mRect.Width, mRect.Height, srcDC, 0, 0, Win32.SRCCOPY);
yourUserControlGraphicsObject.ReleaseHdc(srcDC);
Win32.ReleaseDC(trgDC);
}
Does this help?
Jeff
|
|
|
|
|
|
The same way you read any file, you know and use the file format specification. Unless of course you are a magician and then you can just use magic.
|
|
|
|
|
Oh.. so kind of you for showing your magic show here Mike. I appreciate it.
But I think you must have missed the actual question that was posted in asp.net forum originally.. which is how to connect to idx file and show the data on the page instead of getting it from the actual db server.
-----
|
|
|
|
|
SABhatti wrote: But I think you must have missed the actual question that was posted in asp.net
No i did not miss it. So my answer is still the same. Do you not understand my answer?
|
|
|
|
|
well, I know that I can read the file like any other file. but I don't know how to read the data from idx file along with its schema. In short I am looking for way to connect to idx files using username and password, if you can give any tip that will be good.
-----
|
|
|
|
|
SABhatti wrote: looking for way to connect to idx files using username and password,
Since you didn't specify I am guessing you mean the Database username and password, is that correct?
If so, in your last post you said this:
SABhatti wrote: instead of getting it from the actual db server.
So you want to get it without using the database server by using the database server, is that about it?
|
|
|
|
|