|
Hello Everybody!!!
I have one problem parsing Xml file iam using the following sheet for the xml file of mine as the code below.
<code>
<article>
<letter from = "my email address">
<subject>any subject here</subject>
<paragraph>any paragraph</paragraph>
</letter>
</article>
</code>
Now from the code above it is simple xml file but i want to know how can i retrieve the attribute value which is the email address from the attribute "From".
I know how can i access subject and paragraph but i want to know how can i access the values of attributes please any one can give me example with code please to understand how can i do such actions.
Please everybody Help me with this problem please.
Iam so appreciateful for you all.
Thanks everybody.
Mess With The Best And Die Like The Rest
-- modified at 17:05 Friday 28th October, 2005
|
|
|
|
|
Hi there,
You can use XPath quere to retrive value of attribute
Take a look on this article
Xml
<< >>
|
|
|
|
|
|
I am trying to write a function that will return the reference of a textbox control on a form. I come from a classic VB background. The questIon i have is how do i pass around a control in a variable? In VB, i could put the control in a generic Textbox variable and pass it around. But when i do this in C# nothing seems to happen. I am unable to change the textbox properties. What is the HowTo for C#? Thanks.
private void LoadCellMatrix()
{
int row;
int col;
System.Windows.Forms.TextBox textboxRef;
for(row = 1; row <= 4; ++row)
{
for(col = 1; col <= 4; ++col)
{
textboxRef = ReferenceCell(row, col);
textboxRef.Text = "TEST" + row + ", " + col;
}
}
}
private System.Windows.Forms.TextBox ReferenceCell(
int row,
int col)
{
string cellName;
cellName = "txtRow" + row + "Col" + col;
System.Windows.Forms.TextBox textboxRef;
// get compile error if i do not assign to something
textboxRef = this.txtRow1Col1;
switch(cellName)
{
case "txtRow1Col1":
textboxRef = this.txtRow1Col1;
break;
case "txtRow1Col2":
textboxRef = this.txtRow1Col1;
break;
}
return textboxRef;
}
|
|
|
|
|
redfish34 wrote: switch(cellName)
{
case "txtRow1Col1":
textboxRef = this.txtRow1Col1;
break;
case "txtRow1Col2":
textboxRef = this.txtRow1Col1;
break;
}
I assume that second case is supposed to read textboxRef = this.txtRow1Col2; ?
What you are doing should work. You declare a TextBox variable and give it a reference to the TextBox you're interested in. What exactly do you mean by nothing happens?
|
|
|
|
|
The "nothing" problem was that the first textbox would not update with any text. After fiddling around with the code and recompiling- not really changing anything- everything magically works now. I had this experience with classic VB and ASP. Sometimes things just don't work- then later would work. You scratch your head for hours wondering what the heck you are overlooking. Since i am new to C# i was not sure if the problem was me or the microsoft IDE. I guess i am going to have to get in the habit of recycling the computer power when i run in "mysterious" circumstances again. This is one way to overcome these glitches. FYI, i am using visual studio 2003.
But thanks very much for confirming that i did good. I posted this question on some other forums and got ZERO response. Your help allowed me to rule out "me" as the problem.
|
|
|
|
|
|
You may try this.
private void Form_KeyDown(object sender, KeyEventArgs e)
{
if(e.KeyCode == Keys.F12)
{this.button1_Click(this, null);}
}
"I am a lair" Is this statement true or false ?
|
|
|
|
|
I was stumped by this too, but the answer is simple. Assign the Shortcut property of a MenuItem. This means you need a Menu obviously.
xacc-ide 0.0.99-preview7 now with C#, C, C++, IL, XML, Nemerle, IronPython, Perl, Caml, SML, Ruby, Flex, Yacc, Java, Javascript, Lua, Prolog and Boo highlighting support!
|
|
|
|
|
I've got that functionality on a a few larger dialogs, but I wanted help to be F1 even on the small modal ones. LongHC gave exactly want I wanted though.
|
|
|
|
|
Hi All
I have some application that i need to get parameters from the user and open Windows Form in the size that this user choose.
How can i change Windows Form in the run time ? [real time] ?
Thanks.
|
|
|
|
|
If you are changing the parent form then use:
this.Size = new Size ( width, height );
if you are opening a new window then:
Form form2 = new Form();
form2.Size = new Size(300,300);
|
|
|
|
|
Modify the Size atribute.
To have a form resize itself do this:
this.Size = new Size(width,height);
You'll need to look into anchoring (or possiby docking) your controls to grow/reposition them when the form changes it's size. If you're using 05 you could also try the layout manager. In 03 for anything complex you might have to handle the resize event yourself.
|
|
|
|
|
I have a large project that early on a class was defined as "Blocks". There was grandious plans for this class, but as the project developed, "Blocks" became a place for a few constants. I would like to change this "Blocks" to "Constants", but the term "Blocks" is used EVERYWHERE in the program. The only certainty is that if I did a simple search and replace, I would screw at least 100 things up. I heard a rumor there is a smart replace for variable names/etc. I found very little info on it. Has anyone used it. Does anyone know if it will work on classes.
Thanks in advance...
Dwayne
*****************
"We need to apply 21st-century information technology to the health care field. We need to have our medical records put on the I.T." —GW
|
|
|
|
|
If you're using VS2005, it supports refactoring[^]. If not, there are tools available for previous versions of VS, such as this one: ReSharper[^]. I am not aware of any free tools, though truth be told I have never looked for them.
Jon Sagara
As you may presently yourself be fully made aware of, my grammar sucks.
Sagara.org | Blog | My Articles
|
|
|
|
|
Refractoring is the rumor I heard about. I am using 2003... Any thoughts on switching to 2005 mid project??? shouldn't be any issues right???
*****************
"We need to apply 21st-century information technology to the health care field. We need to have our medical records put on the I.T." —GW
|
|
|
|
|
It's hard to say, and only you and your team can make that call, but my gut reaction is that if you just want the refactoring, then no, don't switch mid-project.
Jon Sagara
As you may presently yourself be fully made aware of, my grammar sucks.
Sagara.org | Blog | My Articles
|
|
|
|
|
You could use "manual refactoring". Just rename the class and compile. The list of compile errors are references to everywhere you use the class. Double click an error and you end up in the file with the name selected. Just paste in the new name.
---
b { font-weight: normal; }
|
|
|
|
|
I have stored my PDF files in the database as binary code.
Now i want to retriee the the binay format file and want to display to my user.
But when ever i have tried the file is not visible. Why? Any help..
Your help highly appriciated!I have written below code..
Basically i want to show the report to the user, I like to store in memory rather physically storing the report in hard drive.
Or do we have any better way to display the report to my user from database (But constraint is File should show in PDF format only!)
string strString= "Select Image From ImageTable where ID=1"
SqlConnection connection = new SqlConnection(connectionstring);
connection.Open();
SqlDataAdapter da = new SqlDataAdapter(strSpName, connection);
da.SelectCommand.CommandType = CommandType.Text;
DataSet ds = new DataSet();
// Fill dataset
da.Fill(ds,"Image");
if (ds.Tables[0].Rows.Count > 0)
{
byte[] Myimage= new byte[0];
DataRow dr;
dr=ds.Tables["Image"].Rows[0];
Myimage = (byte[])dr["NoticeImage"];
int ArraySize = new int();
ArraySize = Myimage.GetUpperBound(0);
FileStream fs = new FileStream(@"C:\Temp\image.pdf", FileMode.OpenOrCreate, FileAccess.Write);
fs.Write(Myimage, 0,ArraySize);
fs.Flush();
fs.Close();
File.Open(@"C:\Temp\image.pdf", FileMode.Open);
}
|
|
|
|
|
Does the file's size seem correct. if not then you may not be writing the bytes correctly.
|
|
|
|
|
The file is storing in C:\Temp\image.pdf with out any Issue. I can open the file manually.. Once i tried File.Open C:\Temp\image.pdf , file is not visible. I am not sure either we need to specify like Activate/Show. How can it is visible?
|
|
|
|
|
|
hello.
Use the following code snippets.
<br />
System.Diagnostics.Process.Start("string to your local path string retrieved from the database");<br />
I hope that will help.
Mess With The Best And Die Like The Rest
|
|
|
|
|
Hey
this is the code and than I will explain the WEIREDEST problem ever.
for(int cnt = 0 ; cnt < sWord.Length ; cnt++)
{
aLabel[cnt] = new Label();
aLabel[cnt].Text = "_";
aLabel[cnt].Location = new Point(30 + (cnt*10) , 200);
this.Controls.Add(aLabel[cnt]);
}
sWord is a member string which is length is 15.
aLabel[] is an array of Labels which has 15 slots. (the same length as sWord)
what I want to do is to put 15 "_" one after another with a space of 10px
between them. pretty simple, but for some reason, no matter WHAT I am doing, c# puts all the labels one over the other, at (30, 200)! I really don't know why its ignoring the (cnt*10).
I tried to do it all speratly, by creating a point object and an int variable, hoping it would help, but it doesnt...
I'm really out of ideas.
Help anyone???
THANKS!
|
|
|
|
|
What I see here is that the for loop could throw an out of bounds exception.
rewrite:
for( int cnt = 0; cnt < sWord.length - 1; cnt++)
{...}
//this is because the length of a string is not base 0.
The second part about the label that is drawn in the same location. Can you post that code? From whats posted here I cannot identify the problem.
have you tried to step through the debugger looking at each label's location to see if its properly created?
try setting the x,y values for your point to variables and set the variables before setting the location of the label.
|
|
|
|