|
Hi, do you use AxWebBrowser? If yes then webBrowser.Navigate("some.mht", ...) will do this work.
|
|
|
|
|
I have a custom control that has a StringCollection property:
private StringCollection _images = new StringCollection();
[Category("_Hotspot"),
TypeConverter(typeof(StringCollectionConverter)),
EditorAttribute("System.Windows.Forms.Design.StringCollectionEditor, System.Design", "System.Drawing.Design.UITypeEditor, System.Drawing")]
public StringCollection Images
{
get {return _images;}
set {_images = value;}
}
I want to be able to edit it at design time, so I wrote a type converter to translate it into a string and back in the attribute:
public class StringCollectionConverter : TypeConverter
{
public override bool CanConvertFrom(ITypeDescriptorContext context, Type sourceType)
{
if (sourceType == typeof(string))
return true;
else
return base.CanConvertFrom(context, sourceType);
}
public override bool CanConvertTo(ITypeDescriptorContext context, Type destinationType)
{
if (destinationType == typeof(StringCollection))
return true;
else if (destinationType == typeof(InstanceDescriptor))
return true;
else
return base.CanConvertTo(context, destinationType);
}
public override object ConvertFrom(ITypeDescriptorContext context, System.Globalization.CultureInfo culture, object value)
{
if (value is string)
{
string[] v = ((string)value).Split(new char[] {','});
StringCollection stringList = new StringCollection();
for (int i=0; i<v.Length; i++)
{
stringList.Add(v[i]);
}
return stringList;
}
return base.ConvertFrom(context, culture, value);
}
public override object ConvertTo(ITypeDescriptorContext context, System.Globalization.CultureInfo culture, object value, Type destinationType)
{
StringCollection stringList;
if (destinationType == typeof(string))
{
stringList = (StringCollection)value;
string result = "";
for (int i=0; i<stringList.Count; i++)
{
result += stringList[i];
if (i < stringList.Count - 1)
result += ",";
}
return result;
}
else if (destinationType == typeof(InstanceDescriptor) && value is StringCollection)
{
stringList = (StringCollection)value;
ConstructorInfo ctor = typeof(StringCollection).GetConstructor(new Type[] {});
if (ctor != null)
return new InstanceDescriptor(ctor, new object[] {});
}
return base.ConvertTo(context, culture, value, destinationType);
}
}
I'm able to click the elipse in the editor, bring up the string collection editor, and enter strings. The strings are written out properly as a comma delimited list in the attribute of the control, but when I run the app, those values are never initialized into the string collection at runtime.
This seems like a lot of work to have a simple collection of strings as a property. Does anyone know how to make this work? I've been searching the web trying to figure this out for days. Lots of people ask about it, but no-one really seems to have the answer. Thanks.
Jason
|
|
|
|
|
Hi,
you would have much less work to change your property to type string[] . This one is fully supported by the IDE. If you still need the collection you could just make a second one which just acts as a wrapper for the designer and internally modifies the collection.
|
|
|
|
|
If I try to use string[] for the property, after I populate it in the editor at design time and switch to look at the source, it writes the attribute as "String[] Array". What do you mean, it's fully supported by the IDE?
|
|
|
|
|
Yes it is. The TextBox has a Lines property which behaves exactly the same way. Notice the little '+' left of the text 'String[]-Array'? Click it you'll see all single elements of the array.
|
|
|
|
|
There's no + sign next to the property in the property grid. There is an elipse to the right of it that brings up a "String collection editor," which I did not specify.
Like I said before, it writes 'String[]-Array' as the attribute for the property in the SOURCE CODE of the page. The strings themselves do not get recorded properly in the source of the page.
I'm using VS 2005, if that makes a difference.
I'll try adding a typeconverter, but I feel like I'm just going back down the same road I took with the StringCollection type.
Edit: After I populate the array in the string collection editor, I do see a + next to the array in the editor, as you said. But it still doesn't populate it in the source properly.
Edit: I got it working! It turns out there's a prebuilt type conerter for string arrays, and I just had to specify it above the property:
TypeConverter(typeof(StringArrayConverter))
Now everything propagates properly. Thanks for the advice!
-- modified at 13:15 Thursday 20th July, 2006
|
|
|
|
|
The only thing I can think of is that this somehow behaves different in web application (I don't know why it should though). I've just tested it for a winapp and it works...
|
|
|
|
|
Hello,
is it possible to launch an other program,
for example notepad as MDI Child in your programs MDI Parent?
Im making a funny Fake OS for my friend and it would be cool if this is possible.
I hope someone can help me,
Thanks
|
|
|
|
|
No, it isn't.
Dave Kreskowiak
Microsoft MVP - Visual Basic
|
|
|
|
|
|
|
1 because i want to do this in C#!
2 i thought the most things of VB.Net are possible in C# and maybe he didnt know it was possible in VB.Net, and maybe there are other people.
no offence
|
|
|
|
|
See this and rewrite it using C#.
http://www.thescripts.com/forum/thread46983.html
|
|
|
|
|
thanks!, ill try!
(so it is possible(probally))
|
|
|
|
|
You can put any window inside another.
use SetParent.
You could show Notepad's window inside you button if you wanted.
Eran Aharonovich (eran.aharonovich@gmail.com )
Noviway
|
|
|
|
|
I am doing some development work with a login page passing a
Session["name"]= this.txtLogin.Text;
Session["Program"] = "PromoLeads";
Response.Redirect(url.ToString());
The database returns 1 or 0 based if the password and user matched. However this will not work with IE 6.0 on a Windows 2003 Server IIS. But it will work on a Windows 2000 IIS. If I use firefox it works fine regardless of what server its going to.
My question is, is there a setting on the IIS server (W2003) that I am over looking?
Thanks
|
|
|
|
|
Through reading forums and pages. My server name has an _ (Underscore) in the name, there seems to be some sort of bug with that based on a security property.
The options to fix this is use the IP address for the server instead of the name or rename the server if thats an option. There are other options as well, however, this was the easiest.
|
|
|
|
|
Hi all,
I'm having problems with SetNotificationPositions, using Managed DirectSound with C#.
Basically, I'm using a SecondaryBuffer in streaming mode, so I'm looping through it and continually adding new data. Eventually I come to the end of the data so I want to set a Notify point in the buffer so that when the buffer gets to playing the end of the data it can throw a notify and be stopped. So I call SetNotificationPositions on the (running) buffer.
However, sometimes, seemingly at random, SetNotificationPositions throws an InvalidCallException - unhelpfully the docs don't give me any idea when or why it throws this.
I can provide (extensive) code samples but I just wondered if this was a known problem and anyone could shed any light on why it's happening.
Cheers,
Tom
|
|
|
|
|
I have a list<t> such as for example:
// simplfied class:
class someObject{
private int i;
setI(int i)
{
this.i = i;
}
}
List<someobject> list1 = new List<someobject>
list1.add(someObject);
list1.add(someObject);
list1.add(someObject);
so there are objects in the list that store integers or some other numerical values.
Now I need to get the object that stores the largest element:
so I tried this:
someObject s = GetLargestObject();
public someObject GetLargestObject()
{
double largestobject= 0;
return list1.Find(delegate(someObject o)
{
if (o.I > largestobject)
{
largestobject= o.I;
}
return true;
});
}
of course that doesn't work...any ideas on how to get this to work?
Is there a way to get find to work?
_ra
|
|
|
|
|
Then you can sort the list using the comparer.
A man said to the universe:
"Sir I exist!"
"However," replied the Universe, "The fact has not created in me A sense of obligation."
-- Stephen Crane
|
|
|
|
|
I know I can sort it, the thing is I need to preserve the order.
One way of course would be to copy the list and then sort the copy, but again I don't want to do this.
_ra
|
|
|
|
|
You don't need to sort the list. Just iterate through the list and use the comparer to compare the current item with the currently largest item. Alternatively, implement a CompareTo() method on your object. (You'll still need to iterate thru the list).
/ravi
My new year's resolution: 2048 x 1536
Home | Music | Articles | Freeware | Trips
ravib(at)ravib(dot)com
|
|
|
|
|
public class SomeObject {
private int i;
public Int Value {
get { return i; }
set { i = value; }
}
}
class Thingy {
List list1 = null;
private SomeObject GetBiggest() {
SomeObject biggest = null;
foreach (SomeObject so in list1) {
if (biggest == null || biggest.Value < so.Value) {
biggest = so;
}
}
return biggest;
}
}
Try code model generation tools at BoneSoft.com.
|
|
|
|
|
Hi,
Can any body tell me how to run any custom application depending upon the file extension through the code in .NET, for example if the file is "test.doc" then checking the extension, the MS Word application is launched and the document is opened... how can we encorporate that in .NET code...
Thanks,
Regards.
|
|
|
|
|
Hi, you can use Process.Start() method. It will open an application wich is associated with the file extension.
System.Diagnostics.Process.Start(fileName)
|
|
|
|