|
What is the easiest way to overcome the following problem?
Controls created on one thread cannot be parented to a control on a different thread.
I have (rather had, struggle to figure it out again a very complicated way using a public delegate on the parent form and calling it in a very "strange" way when the event was fired.
Thanx all for replying
READ MSDN
|
|
|
|
|
Why do you want to do that? I never ever undertood the need to have two separate GUI threads in an app?
|
|
|
|
|
thx
An event is fired from a threaded TCP connection. EG in my case, i receive a joined event from the network thread. The executed method for the event is executed on the network thread and not on the GUI thread, hence the error.
READ MSDN
|
|
|
|
|
|
It's System.Windows.Forms
|
|
|
|
|
|
Don't feel embarrassed, it was changed from beta to release.
|
|
|
|
|
here's another one,
BorderStyle =FormBorderStyle.FixedDialog;
to set the border style, and it says it is a class where a vairable is expected
[sry for the n00be Q's, but im a n00be to c#]
Email: theeclypse@hotmail.com URL: http://www.onyeyiri.co.uk "All programmers are playwrights and all computers are lousy actors."
|
|
|
|
|
Nnamdi Onyeyiri wrote:
BorderStyle =FormBorderStyle.FixedDialog;
like:
form.FormBorderStyle = FormBorderStyle.FixedDialog; or this.FormBorderStyle = FormBorderStyle.FixedDialog; if you are calling from the form. Note the object reference (form or this )
Are you sure you are not using an old version of SharpDevelop (latest available on sourceforge.net , latest ver 0.88b??? ) or the .NET Framework.
READ MSDN
|
|
|
|
|
iam sing the latest version, its just that i was using an add-in for vs6 that turns your dialog resource into c# code [co0l aint it] it does not have support for all controls but that can be added fairly easy [so its stated]. I found this article on CodeGuru [newin].
Email: theeclypse@hotmail.com URL: http://www.onyeyiri.co.uk "All programmers are playwrights and all computers are lousy actors."
|
|
|
|
|
How can I change setting in IIS programmitically.For example change read/write permission of web applications in IIS.
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
|
|
|
|
|
Same thing again: System.DirectoryServices with the IIS provider. MSDN has the documentation under IIS programmers guide.
This sample will dump out the entire structure of the metabase:
using System.DirectoryServices;
...
void testIIS() {
DirectoryEntry oDE = new DirectoryEntry("IIS://localhost/W3SVC");
Console.WriteLine("[{1}] {0}", oDE.Path, oDE.SchemaClassName);
recurseObj(oDE.Children, 1);
oDE.Dispose();
}
void recurseObj(DirectoryEntries parent, int level) {
if (parent==null) return;
foreach (DirectoryEntry oDE in parent) {
Console.Write(new String(' ', level * 2));
Console.WriteLine("[{1}] {0}", oDE.Path, oDE.SchemaClassName);
recurseObj(oDE.Children, level + 1);
oDE.Dispose();
}
}
|
|
|
|
|
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
|
|
|
|