|
Thank you for your help.
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 am trying to list all the local users, groups, domains etc attached to the
local machine.
I haven't been able to find anything in the .net docs. I am not sure if there
is no support for it due to the .net environment being a standalone run time.
Thus having to call the win32 api directly in order to accomplish this task.
I was reading into the WMI without any joy.
Any thoughts.
|
|
|
|
|
Use System.DirectoryServices with the WinNT provider. It's pretty much the same as using ADSI.
|
|
|
|
|
|
Hi all,
ComboBox.SelectedValue dont seem to work correctly. Code:
...
void SetupCustomers(){
cbCust.DataSource = dbase.GetCustomers();
cbCust.DisplayMember = "Name";
cbCust.ValueMember = "ID";
}
...
However when calling cbCust.SelectedValue returns the wrong value. Calling ((Customer)cbCust.SelectedItem).ID gives the correct answer.
This seems to be a problem with the DisplayMember being (automatically) sorted as all the returned SelectedValue's are within range.
EG : Customers[] expanded may look like this:
ID(Value) Name(Display)
20 Ben
21 John
23 Ann
26 Frank
27 Arnold
The combobox will display the Displaymembers in alphebetical order. Here is where the problem lies (i think ):
Value Display
20 Ann
21 Arnold
23 Ben
26 Frank
27 John
Now this is how Mr. ComboBox display and intepret Value and Display members, thus getting the mappings all wrong.
If anyone has had a similar experience or can spot where I made a mistake, please tell me
Thanking all replies in advance
Cheers
READ MSDN
|
|
|
|
|
I don't suppose you're setting the Sort property on the combobox? If not maybe an explicit set to false would do the trick
|
|
|
|
|
Thanx Chris, however...
1. no the Sort property is not set.
2. but Sorting is really needed.
Like i said a quick work around does the trick, but i have searched forums and articles with nothing pointing to what i experience.
READ MSDN
|
|
|
|
|
I was able to reproduce the behavior doing to following:
I made a class: test with properties Name and Id.
Set the ComboBox's DataSource to a test[] With Name as DisplayMember and Id as ValueMember
Set Sorted=true
Noting that I had to set sort before setting the DataSource property otherwise it will throw an exception.
In thinking about it the behavior makes sense that it could happen this way. When you set the DataSource of a ComboBox it copies the list to its own internal list.
Text returns the item in the internal list. SelectedValue uses a combiniation of CurrenctManager ,SelectedIndex and ValueMember to retrieve an Item from the datasource. SelectedItem is probably a pointer stored in the internal list that gets Sorted with Text.
Anyways Sorting your DataSource (via Array.Sort, ArrayList.Sort, DataTable.DefaultView.Sort; whatever the type of DataSource you have) should fix the problem. Even if the
Sorted property inadvertantly gets set on the combobox, there's no mismatch between your datasource and its internal list because its already sorted.
|
|
|
|
|
thx, i wrote the original UI code a while back so i'll check if i maybe did set it to sort.
my workaround is sufficient for now though
READ MSDN
|
|
|
|
|
How can I create a Bitmap from a piece of another Bitmap? (I have a 100x100 sized Bitmap and want to create a new bitmap from a 10x10 piece inside the big bitmap)
Ø.
|
|
|
|
|
Bitmap GetPiece(Bitmap src, Point loc, Size size)
{
Bitmap bmp = new Bitmap(size.Width, size.Height);
Rectange rSrc = new Rectangle(loc, size)
Rectangle rDest = new Rectangle(0, 0, size.Width, size.Height);
using(Graphics g = Graphics.FromBitmap(bmp))
{
g.DrawImage(src, rDest, rSrc, GraphicsUnit.Pixel);
}
return bmp;
} To get the 10x10 piece located at 7, 4 use this code:
Bitmap bmp = GetPiece(sourceBitmap, new Point(7, 4), new Size(10, 10));
HTH,
James
"Java is free - and worth every penny." - Christian Graus
|
|
|
|
|
Thanks, James!
I didn't know you could create a Graphics object from a bitmap and draw on it.
It solved my problem.
Øyvind
|
|
|
|
|
Hi,All
I want to drag node from one treeview and drop it on another.
I am able to drag it from source tree view,while i drop it on target treeview i want to know on which node of target treeview user has droped the data from source treeview.
DragDrop event of target treeview is like this
private void treeView2_DragDrop(object sender, System.Windows.Forms.DragEventArgs e)
{
System.Windows.Forms.TreeNode trn = new System.Windows.Forms.TreeNode();
trn = treeView2.GetNodeAt(e.X,e.Y)??? (co-ord of source treeview)
}
In this event how should i get mouse Co-ordinates where the user has droped the data,so that i can get the node?
Or is there any other way?
Please reply to this..
Thanks
Tushar
|
|
|
|
|
Try
MousePosition.X and MousePosition.Y
-Ø.
|
|
|
|
|
Hi,
MousePosition.X and MousePosition.Y returns the co-ordinates relative to Screen.
Is there any way to convert them to co-ordiantes related to treeView?
Thanks
Tushar
|
|
|
|
|
Try using PointToClient on the treeview.
|
|
|
|
|
When the MemoryStream is closed you can still get the data in the stream using GetBuffer - but I cannot get the length of the data in the stream - an exception is thrown saying stream is closed. I know what you are going to say is don't close the stream but I don't have a choice as this stream has been manipuated by the CryptoStream class and to process the last block I have to call Close and that in turn closes my MemoryStream - I can understand not being able to manipulate the position in the stream but not allowing to see the Length when closed seems a bit odd. Can anyone help - I am considering writing my own memory stream type class if I can't work this out.
|
|
|
|
|
|
Alas I wish it was that simple - it tells me that the length of my buffer is 0x100 (256) but I know that the encryped data will only 2 blocks (32 bytes) so that is not a good indication - examining the MemoryStream it tells me that the position and length is 0x20 but I cannot access that data directly
However I think I have it - if I use ToArray() - then I get a buffer that only contains the data and is of the correct length - just a bit convoluted and it still doesn't explain why you cannot get the Length property on a Closed Stream
> p.s. Are you sure you can call GetBuffer on a closed stream
yup - it doesn't throw any exceptions and the data is fine to use later
|
|
|
|
|
I want to write a program for IIS with C#.Which class should I use? If I have to use win32 api what are the names of functions related to IIS in win32?
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
|
|
|
|
|
What do you mean by "a program for IIS"? A website, an ISAPI filter, an MMC snap-in, etc?
James
"Java is free - and worth every penny." - Christian Graus
|
|
|
|
|
I want to write a application for administrating user accounts.Does "active directory" programming useful for it? I THINK System.DirectoryServices namespace is what I want.
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
|
|
|
|
|
If your users are in Active Directory (NT user accounts), then System.DirectoryServices is the right place to start, using either the WinNT or LDAP providers. MSDN has some good documentation, or check out http://www.15seconds.com/focus/ADSI.htm.
|
|
|
|
|
Thank you Richard.What about IIS setting?
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
|
|
|
|
|
The simplest method:- In IIS, properties of the application root, turn off anonymous access, and turn on basic or integrated authentication;
- Enable impersonation in web.config;
- Log in as a user with permissions to access / modify Active Directory objects, e.g. administrator;
If you want to get more complicated, you can pass login credentials to the DirectoryEntry object, but this could expose the directory to anonymous users.
|
|
|
|