|
how to insert an image in word file through C# 2008....
please send me the code to insert an image in a word file through C# 2008
csetopper_bhanu
|
|
|
|
|
hello once again today -
I do have one more question and I hope that someone can help me one more time today again. I have an xml document similar to this one:
<xml>
<person id="1">
<first>John</first>
<last>Smith</last>
</person>
<person id="2">
<first>Mark</first>
<last>Smith</last>
</person>
</xml>
I want to get partial xml data, for example I want to get just the second person data, and I want to get based on the attribute, in this case the ID. Is there a way how to do that? Thanks in advance, Laziale
|
|
|
|
|
You'll have to write some code.
|
|
|
|
|
How insightful
only two letters away from being an asset
|
|
|
|
|
Yes; look into XPath queries. The correct query would be something along the lines of "//xml/person[id='2']". You simply have to plug that into and example like this; there are other examples you could use as well
Between the idea
And the reality
Between the motion
And the act
Falls the Shadow
|
|
|
|
|
You can use an XPath expression to retrieve the xml fragment, ./person[@id='2'] will return the second person element in this case
only two letters away from being an asset
|
|
|
|
|
ok, sorry everyone cause I didn't provide any code, but here is what I tried:
string innerXml = "";
innerXml = docCompany.Attributes[selectedItem].OuterXml;
and it give me an error NullReferenceObject
any other way?
|
|
|
|
|
|
You should look into LINQ for this, I absolutely LOVE LINQ when working with XML files.
http://www.codeproject.com/KB/linq/LinQ_To_Xml.aspx
That's a good article that shows pretty much exactly how to do what you need.
Sorry for the crappy link, all the fancy JavaScript that formats it doesn't work on my iPhone (stupid safari)
If at first you don't succeed ... post it on The Code Project and Pray.
|
|
|
|
|
Hello ,
Virtual keyword allows us to override that method in child class.
Now when we declare a class as sealed class then we cant inherit . In That case why it allows us to decalre virtual keyword in static class when any other class inherit it ?
Pls expaln in deatils
Regards,
Jaddu
|
|
|
|
|
It will not allow you to declare a virtual method in a sealed class. You can't have instance members in a static class as well.
|
|
|
|
|
You can't, what makes you think you can?
|
|
|
|
|
You can't. Have you tried it?
In a static class, if you try to create a virtual method the compiler will spit at you with
A static member cannot be marked as override, virtual, or abstract
In a sealed class
... is a new virtual member in sealed class ...
DaveBTW, in software, hope and pray is not a viable strategy. (Luc Pattyn) Visual Basic is not used by normal people so we're not covering it here. (Uncyclopedia) Why are you using VB6? Do you hate yourself? (Christian Graus)
|
|
|
|
|
Hey guys,
Can anyone help me in writing the simple regex. Here is the situation:
I have a text file something like:
// Contents
// Contents
MyDataBlock
{
@$
The datablock text
@$
}
// Contents
// Contents
I want to extract "The datablock text". There is single "MyDataBlock" in this text file. It means that i have to extract entire MyDataBlock {...} and then what is inside @$ into a regex group.
I've created a regex. It is successfully extracting following in regex group <b>DataBlockContents</b>:
@$
The datablock text
@$
But i don't want @$ in the regex group DataBlockContents. How can i do so ? The regex i created is:
MyDataBlock[\\w\\s]*{(?<DataBlockContents>[^}]*)}
Imtiaz
|
|
|
|
|
The same way you don't get the { and } in the group?
Do you have control over how the file is formatted? Why use @$ instead of something else?
|
|
|
|
|
Is it possible to pull from somewhere after the application has been compiled to know what it's build version number is so I can show it in a label? I am thinking I can pull if from the assembly but my attempts have failed. Please can someone point me in the right direction?
Here is what I am currently doing and it does not match the build version of the application that I am compiling.
lblAppVersion.Text = "Version: " + System.Reflection.Assembly.GetExecutingAssembly().GetName().Version.ToString() + " or " + System.Reflection.Assembly.GetCallingAssembly().GetName().Version.ToString();
|
|
|
|
|
Are you looking for something like this?
labelControlVersion.Text = string.Format ( "Version: {0}", Assembly.GetExecutingAssembly ( ).GetName ( ).Version ) ;
|
|
|
|
|
Not quite I want the applications build version... which would show on the project properties screen under the publish tab.
any idea where this is?
|
|
|
|
|
What do you want the text in the label to look like?
To Get This "Ver. 5.1.2 Rev. 3"
Try like this;
Dim avi As System.Version = System.Reflection.Assembly.GetExecutingAssembly.GetName.Version
lblVersion.Text = "Ver. " & Format(avi.Major, "###0").TrimEnd & "." _
& Format(avi.Minor, "###0").TrimEnd & "." & Format(avi.Build, "###0").TrimEnd _
& " Rev. " & Format(avi.Revision, "###0")
Of course this is not the publish version (just saw last post)
|
|
|
|
|
it is very easy tog et this info
This is a code for this
Version v = System.Reflection.Assembly.GetExecutingAssembly().GetName().Version;
lblVersion.Text = v.ToString();
This information is stored in the AssemblyInfo.cs under Node 'Properties' in Solution explorer!
Reg,
Deep
Happy Coding!
|
|
|
|
|
Thanks I learned that c# does not auto increment the version per each build. That was the issue I was having.
|
|
|
|
|
I am having a problem changing the forecolor of a DataGridView header. I have tried the following code:
dgvMaintenance.EnableHeadersVisualStyles = false;
DataGridViewCellStyle dgvcs = dgvMaintenance.ColumnHeadersDefaultCellStyle;
dgvcs.BackColor = System.Drawing.Color.DarkGray;
dgvcs.ForeColor = System.Drawing.Color.White;
The backcolor changes, but the forecolor does not.
I have also tried:
dgvMaintenance.EnableHeadersVisualStyles = false;
DataGridViewCellStyle dgvcs = new DataGridViewCellStyle();
dgvcs.BackColor = System.Drawing.Color.DarkGray;
dgvcs.ForeColor = System.Drawing.Color.White;
dgvMaintenance.ColumnHeadersDefaultCellStyle = dgvcs;
with the same results. I have also added code to change the font and that works too.
What am I doing incorrectly? Thank you for any help.
modified on Wednesday, August 5, 2009 12:26 PM
|
|
|
|
|
i need to check that the content in a textbox is a 6-digit hexadecimal number (or rather, an HTML color code).
How do I do this?
|
|
|
|
|
You could use a regular expression.
There's a bunch of regular expression classes in .net (Start here[^]
If you don't know about regular expressions, you might want to read up a bit on them. There's a site here[^] that's worth looking at.
It's also worth having a tool to test them with before you start coding them. A popular one is Expresso[^].
Simon
|
|
|
|
|
use this function...
bool ValidateColor(string s)
{
if(s.Length != 6)
return false;
for(int i = 0; i < 6; i++)
{
int c = (int)s[i];
if(!(c > 47 && c < 58) || !(c > 64 && c < 71))
return false;
}
return true;
}
..should do the job
Life goes very fast. Tomorrow, today is already yesterday.
|
|
|
|