|
I'm trying to update a project to use System.XML.Linq and I'm now happily working with XDocument and XElement etc... It's very cool by the way if you haven't tried it.
The only problem I have is in one method I have to pass the full xml as a string, but XDocument.ToString() only returns the root and child nodes and not the xml header. Previously I used XMLDocument.OuterXML.
I there any equivalent in XDocument or a way of converting an XDocument to an XMLDocument?
*Edit*
I've found a 'dirty' way of doing it:
string xmlString = myXDocument.Declaration.ToString() + myXDocument.ToString(SaveOptions.DisableFormatting);
but there must be a better way than this!
modified on Sunday, January 20, 2008 11:54:14 AM
|
|
|
|
|
What's wrong with the "dirty" way?
"The clue train passed his station without stopping." - John Simmons / outlaw programmer
|
|
|
|
|
Nothing I suppose, I expected a new class specifically designed to work with xml to have a method that would either return the xml as a string, or an XmlDocument at least, for compatability.
I just thought I was missing something obvious.
It appears that the only way to actually get full valid xml out of of it after you've finished manipulating data is to either save it to disk or to use a TextReader.
I've created my own class inherited from System.Xml.Linq.XDocument and added ToXmlDocument() and two ToXmlString() methods (one that allows formatting) so I have the functionality I need.
|
|
|
|
|
hye,
(Using DShowNET)When i call this FindPin(), it returns nagative value.I m calling it like this;
ICaptureGraphBuilder2 capGraph;
IPin pin;
Guid pc = PinCategory.Capture;
Guid pt = Guid.Empty;
int hr = capGraph.FindPin(
Device(which i found attachd),
1,
ref pc,
ref pt,
false,
0,
p);
and it returns negative value(-214...). I checkd the parameters during debugging, no problem in them then Whats wrong m i doing?
B!z
|
|
|
|
|
B!Z,
I don't know anything about ICaptureGraphBuilder2, but from your code you don't construct the capGraph or pin object.
This might be the problem...
Regards,
Gareth.
|
|
|
|
|
No. coz last time when another function returned this same negative value (-214...), the problem was not in that function itself. And BTW i wrote "ICaptureGraphBuilder2 capGraph;", its not actually like that(coz the code was bit lengthy so included that method only). i just wanted to tell that capGraph is actully its object.Anyways thx for the reply.
Anyone else who worked using DShowNET by .NET master?
B!z
|
|
|
|
|
Hi all,
I have a question regarding a Listview focus: Whenever this control loses focus to another control (e.g. checkbox that's being clicked at the same form), the selected lines are switched from blue to grey. Is there a way to keep the listview always focused, without calling its Focus() method every time another control gets it?
Thanks a lot,
Eyal.
|
|
|
|
|
I assume you mean that you want it always to appear the same as it does when it has the focus.
If so, you'll nead to create your own class inheritting from ListView and override the OnPaint event and possibly the OnLostFocusEvent.
|
|
|
|
|
Hi all,
I need to reconstruct the exact view of a listview after updating it's data. There is no problem if all the lines are visible. However, if some of it is hidden (a situation where a vertical scrollbar appears), updating the list always brings the first line to be first viewed, meaning that some lines that were previously visible are now hidden.
Does anyone knows how to reconstruct the exact location as before the update procedure?
Thanks,
Eyal.
|
|
|
|
|
You best bet would probably be to use the TopItem[^] property.
You would need to get the index of the TopItem before updating the list, then restore the TopItem after the refresh. You will need to take into account the fact that the "saved index" may not exist in the updated list.
Take care,
Tom
-----------------------------------------------
Check out my blog at http://tjoe.wordpress.com
|
|
|
|
|
Or,you can use listView.EnsureVisible(index) ,it will let the item[index] auto visiable .. good luck
|
|
|
|
|
Playing around with the new SyncFramework is proving to be a pain. I can't get one demo application to work and the API Object Model is not as straight forward as one would think. That coupled with major changes of biblical proportions between the Betas and the CTPs is a sure recipe for mayhem.
I'm getting this exception thrown:
Exception: An error occurred when enumerating changes in the client database. Check the inner exception for more details.
InnerException: The column name is not valid. [ Node name (if any) = ut0,Column name = __sysInsertTxBsn ]
Now I got the code off of this article by Rafik Robeal: Clickety[^]
If anyone can shed some light on the subject, please do. I'm this close from giving up as I've been playing around with this framework since the 8th of January.
[edit]
I forgot to add that this issue occurs when the synchronization is set to Bidirectional[default for the demo app] or UploadOnly. Snapshot and DownloadOnly works fine (although the synchronization fails )
"Programming today is a race between software engineers striving to build bigger and better idiot-proof programs, and the Universe trying to produce bigger and better idiots. So far, the Universe is winning." - Rick Cook
"There is no wealth like knowledge, no poverty like ignorance." Ali ibn Abi Talib
"Animadvertistine, ubicumque stes, fumum recta in faciem ferri?"
|
|
|
|
|
Hi all,
I have a design question for an application I'm developing:
At the main GUI screen I'm having a list if items at a listView, where each entry represents a backstage complex object.
Backstage, I have a list of these objects (List<t>). The order of the items at the ListView is the order of the items at the list, meaning whenever I want to sort the ListView according to one of it's columns I'm sorting the list and then call an invalidate function to update the ListView. Think about the windows task manager as a model for this design: list of processes, which can be sorted according to several criterions (e.g name, CPU, mem usage etc.).
To me, it doesn't makes sense that whenever I'm sorting this view a big objects list is being sorted, and this design is causing several problems, for example: I can't sort the ListView while a certain task is running on the List, since the object's order will be changed and a whole mess will occure...
I'll appreciate any good ideas regarding how to separate the ListView from the object's list and still to be able to tie a ListView item with it's corresponding object in a fast and reliable way.
Thanks!
|
|
|
|
|
Good Day to all,
I've read article (http://www.codeproject.com/KB/cs/hard_disk_serialno.aspx ) here in CodeProject that is about retrieving the manufacturer's serial for a certain physical hard drive.
What I need is the one that can get the manufacturer's serial for a FLASH DRIVE, the usb type thing.
Is there any articles on how to do this?
PS: I'm after the real SERIAL, not the WMI type.
Thanks,
Ian
|
|
|
|
|
|
Yes there is. Sorry, that was a misfire. Submitted the original question.
|
|
|
|
|
Have you left a message for the author of the said article? There is a forum at the bottom of the article page.
"The clue train passed his station without stopping." - John Simmons / outlaw programmer
|
|
|
|
|
No, but someone already posted this same question. And the author seems to be already inactive.
|
|
|
|
|
MyReport rpt = new MyReport();
rpt.SetDataSource(MyDataset.Tables[MyTableName]);
rpt.SetParameterValue("MyParameter");
MyReportForm rptForm = new MyReportForm(rpt);
I was wondering if there's a smarter way to do maybe by converting my report once to object but then I cant access all the report's methods and members like the setting the datasource and the parameters.. I was thinking:
object rpt = new MyReport();
rpt.SetDataSource(MyDataset.Tables[MyTableName]);
rpt.SetParameterValue("MyParameter");
<font color="#00aadd">rpt = new AnotherReport();</font>
rpt.SetDataSource(MyDataset.Tables[MyTableName]);
rpt.SetParameterValue("MyParameter");
Thank you guys
Smile: A curve that can set a lot of things straight!
(\ /)
(O.o)
(><)
|
|
|
|
|
EDIT: I reread and understood what was being asked.
You could use an interface or abstract class and do something like:
<br />
IReport rpt = new MyReport();<br />
rpt.SetDataSource(MyDataset.Tables[MyTableName]);<br />
rpt.SetParameterValue("MyParameter");<br />
<br />
rpt = new AnotherReport();<br />
rpt.SetDataSource(MyDataset.Tables[MyTableName]);<br />
rpt.SetParameterValue("MyParameter");<br />
where IReport is:
<br />
public interface IReport<br />
{<br />
void SetDataSource(DataTable source);<br />
void SetParameterValue(string parameter);<br />
}<br />
or if you want to use properties:
<br />
public interface IReport<br />
{<br />
DataTable DataSource { get; set; }<br />
string Parametervalue { get; set; }<br />
}<br />
Then have Report and AnotherReport implement the interface.
|
|
|
|
|
|
How would I, for every 10 numbers in an int, do an event? What I need help with is the foreach part? I'm confused as of what exactly to put: foreach (myInt in ???)
{
}
Thanks.
- I love D-flat!
|
|
|
|
|
Every 10 digits in what int ? You mean as in the int 12345678901 fires one event ? When ? When it's being entered ? If you have a string you can use the length property to check how long it is.
Christian Graus - Microsoft MVP - C++
"also I don't think "TranslateOneToTwoBillion OneHundredAndFortySevenMillion FourHundredAndEightyThreeThousand SixHundredAndFortySeven()" is a very good choice for a function name" - SpacixOne ( offering help to someone who really needed it ) ( spaces added for the benefit of people running at < 1280x1024 )
|
|
|
|
|
int But I don't undertand how to calculate this in the language. foreach (myInt in (what goes here?)
- I love D-flat!
|
|
|
|
|
Convert the number to a string, then loop through the characters in that string.
Paul Marfleet
"No, his mind is not for rent
To any God or government"
Tom Sawyer - Rush
|
|
|
|