|
Hi,
In WinForm .net 2.0, is there a drop down control which allows multiple selections?
Drop down control seems to allow only for a single selection.
Thanks
|
|
|
|
|
No, But you should be able to create one with some effort. Basically you would need to create a control, add in a combobox and a checked list box. Set combobox's ListControl property to the list box. You would need to keep track of selections separately and display it as comma separated text or something similar.
|
|
|
|
|
Hi,
I'm trying to serialize an object which contains an array of Objects, which holds in one of it's elements a generic LinkedList. And when I try to serialize the object, i get a InvalidOperationException, saying that "There was an error generating the XML document.", and no further details. Does anybody know what can cause this, and how to resolve it?
Here's the example code (doesn't work):
[XmlRoot()]
public class TestObj
{
private Object[] array = new Object[2];
public TestObj()
{
}
[XmlArray()]
public Object[] Items
{
get { return array; }
set { array = value; }
}
}
class Program
{
static void Main(string[] args)
{
TestObj t = new TestObj();
LinkedList<String> list = new LinkedList<string>();
list.AddLast("abcdef");
t.Items[0] = list;
t.Items[1] = 123;
XmlTextWriter wr = new XmlTextWriter("test.xml",Encoding.UTF8);
XmlSerializer s = new XmlSerializer(typeof(TestObj));
s.Serialize(wr, t);
wr.Close();
}
}
|
|
|
|
|
Do the following:
[Serializable]
public class SerializableLinkedList<t> : LinkedList<t>, IXmlSerializable, ISerializable {
...
}
</t></t> Then instantiate and use that class instead (in your example, the ISerializable interface is optional). Hope this helps,
Sounds like somebody's got a case of the Mondays
-Jeff
|
|
|
|
|
Thanks for the reply,
The Serializable attribute and ISerializable are connected with regular serialization, not XML serialization. So marking the class as Serializable or implementing ISerializable won't solve the problem.
As for IXmlSerializable, it would probably work, but I would have to implement my own xml serialization routines for the LinkedList, which would lead to adding an amount of unnecessary code (and I would need to do the same for other collection classes, like List<> or Dictionary<>, which also cause the same problem), and it's not what I would want to do.
If I won't find any other way to solve this problem, I think I'll just use a BinaryFormatter to serialize this class.
|
|
|
|
|
In my example, it is true that implementing ISerializable is unnecessary, but you would still have to implement the constructor that normally goes along with that interface (or you would get a deserialization error if you attempted binary serialization). I think that in the .Net 3.0 framework you can add extensions to classes that you would otherwise not have access to, so you may look into that if you have the 3.0 framework available to develop against. Using this methodology, you could add the methods implemented by IXmlSerializable to the actual collections, but I don't think you can add interfaces (like IXmlSerializable) to the inherited interfaces list. Anyway, good luck, and let us know if you do find an elegant way to go about this.
Sounds like somebody's got a case of the Mondays
-Jeff
|
|
|
|
|
Hi,
I want to develpe a windows application that should be executable in a LAN.
a computer is as server, and another are clients.
Now, I develope it just a standalone application,i.e:
I install application on each client and instal SQL Server on Server and clients use IP address of Server in its Connectionstring
Or I should develope it in another approach?
I don't develope such application before that must be ran in LAN.
Best wishes
|
|
|
|
|
You have the basic idea. It could get more complicated depending on the requirements.
only two letters away from being an asset
|
|
|
|
|
Hello all:
When I was desin a form , it have many radio buttons , how can I save the selected items between the radio buttons on a txt file after I closed the form.
Thanks
|
|
|
|
|
Create the file
Write checkbox.checked value
Close the file
What part don't you understand or are having difficulties with?
only two letters away from being an asset
|
|
|
|
|
Hi:
Sorry , I didn't mean that , when I run my form , inside it there are many radio buttons , when I choose a value , I want this value directly stored in a txt file ........
Thanks
|
|
|
|
|
Handle the selected event and write it to your file.
It would be nice also if you took out all the empty space on your signature line
only two letters away from being an asset
|
|
|
|
|
Hello :
Thank you very much for your intersting , but can you give me an example to do that or explain the steps to do that ,please......
Thanks
|
|
|
|
|
How about at least try something on your own? What part are you having difficulties with? Handling an event? Writing to a file? What? These are not complex topics.
only two letters away from being an asset
|
|
|
|
|
Mark Nischalke wrote: What part are you having difficulties with
Perhaps it was the "taking all the empty lines out your sig" part.
|
|
|
|
|
Hello :
I'll try it myself , but I want to know how can I start deal with handles and write to a file ......
Thanks
|
|
|
|
|
There is a little textbox at the top of the page, the one that has Search next to it. You should try it.
If you find that difficult, perhaps another career would be better.
Take the empty lines out of your signature.
only two letters away from being an asset
|
|
|
|
|
This should get you started.
void button1_Click(object sender, EventArgs e)
{
foreach (Control thisControl in Controls)
{
if (thisControl is RadioButton)
{
RadioButton thisButton = (RadioButton)thisControl;
if (thisButton.Checked)
{
string path=Environment.GetFolderPath(
Environment.SpecialFolder.LocalApplicationData
) + "\\test.txt";
TextWriter textWriter = new StreamWriter(path);
textWriter.WriteLine(thisButton.Name);
textWriter.Close();
Console.WriteLine("Data written to " + path);
break;
}
}
}
}
Now use this to get yourself going and post back with a more specific issue if one arises - and alter that signature!
|
|
|
|
|
Rather than learning some very simple techniques, all he has to to do is copy your code. Hope you will always be around for him. Give him a fish, feed him for a day; teach him to fish...
only two letters away from being an asset
|
|
|
|
|
I take your point and I agree totally, but if he is to learn some simple techniques he needs a starting place. What better place than here? Surely that's part of what CP is about.
You'll notice the code I gave is very vague and pretty much useless. To be put into a pratical situation it would need some significant alteration that would require, and hopefully stimulate, a proper understanding of the code I gave.
|
|
|
|
|
Hello
I want to thank (DaveyM69) about the support, and your advance (Mark Nischalke) is nice but I hope you too when you look at it you didn't copy it, it's a disscusing forum, so what is this forum do if we don't sharing information between us....
Thanks
|
|
|
|
|
//This particular function retreives and displays the currency results of the usered selected input
function DisplayCurrencyValue(link,currency)
{
var str,objXMLNode,objXMLDoc,objEmployee,strHTML;;
var stri=AJAXUtilities.GetCurrencyValue(link,currency);
str = stri.value;
var result=parseFloat(str);
var value=parseFloat(document.getElementById("txtConvert").value)
if(isNaN(value))
{
value=1;
document.getElementById("txtConvert").value=1
}
var city=document.getElementById("ddlTo");
var url=document.getElementById("ddlFrom");
var path=url.options[url.selectedIndex].text;
var pathCurr=url.options[url.selectedIndex].value;
var currencyAbr=pathCurr.substring(pathCurr.length-7,pathCurr.length-7+3);
var curr=city.options[city.selectedIndex].value;
result=result*value;
var str=value+" "+currencyAbr+" = "+ result +" "+curr;
document.getElementById("lblConverResult").value=str;
// document.getElementById("txtConvert").focus();
}
---------------------------------------------------------------
*
*
*
--------------------------------------------------------------
public string GetCurrencyValue(string url, string currency)
{
DataSet ds3 = new DataSet();
ds3.ReadXml(url, XmlReadMode.ReadSchema);
DataTable table = ds3.Tables[3];
string curren = currency.Trim();
string title = "";
string rate = "";
string exchange = "";
string outPut = "";
foreach (DataRow row in table.Rows)
{
title = row["title"].ToString();
int endPoint = title.IndexOf("=");
int startPoint = title.IndexOf("(");
int ePoint = title.IndexOf("(");
rate = title.Substring(endPoint + 2);
exchange = (rate.Substring(0, 3));
if (exchange.Equals(curren))
{
outPut = rate.Substring(5, (rate.Length - 1) - 5);
}
rate = title.Substring(startPoint + 1, 3);
}
decimal tr = Convert.ToDecimal(rate.Substring(0, rate.Length - 1));
tr = tr * 100;
//XmlDocument xmlDoc = new XmlDocument();
return outPut;
}
--------------------------------------------------------------------
-------------------------------------------
Result displaying lick this:
200 USD = NaN INR
plz tell me why hear NaN is displaying..
--------------------------------------------
|
|
|
|
|
NaN - Not A Number?
Try converting all those strings to decimals before doing any calculations and/or comparisons.
|
|
|
|
|
Hi everyone,
I have always held some kind of a fascination with the resource editor in Visual Studio. I could never understand how VS allows a user to drag/resize/modify buttons, edit boxes, and other controls on a dialog inside a window.
Can anyone throw some light on the matter?
Thanks!
_________________________
Kri5
|
|
|
|
|