|
Your treeview text is an xpath to the node ? I doubt that, and suspect that you're erasing the entire document. Did you look in the debugger to see what t is, what gets returned and what the dom XML is when you save ?
Christian Graus
Driven to the arms of OSX by Vista.
"I am new to programming world. I have been learning c# for about past four weeks. I am quite acquainted with the fundamentals of c#. Now I have to work on a project which converts given flat files to XML using the XML serialization method" - SK64 ( but the forums have stuff like this posted every day )
|
|
|
|
|
Hi, is there a way to list the contents of constants?
ie. is there a function ConstantCollection() (see below) or something similar?
class Test()
{
const string c1="blah1";
const string c2="blah2";
const string c3="blah3";
const string c4="blah4";
void Print()
{
foreach(object Constant in <code>ConstantCollection(this)</code>)Debug.Print(Constant.Contents);
}
}
Output:
blah1
blah2
blah3
blah4
Ariadne
|
|
|
|
|
Not that I know of, although if the constants are all of the same type then you could use an enum instead.
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)
|
|
|
|
|
That won't work in this case - enum values cannot be strings.
|
|
|
|
|
But it is possible to attach strings to enums using the Description attribute.
"WPF has many lovers. It's a veritable porn star!" - Josh Smith As Braveheart once said, "You can take our freedom but you'll never take our Hobnobs!" - Martin Hughes.
My blog | My articles | MoXAML PowerToys | Onyx
|
|
|
|
|
I am an idiot! Provided the consts are single words, you can use them in an enum and use the names as const strings.
enum sample
{
Hello = 0,
There,
Last
}
static void Main(string[] args)
{
for (sample t = 0; t < sample.Last; t++)
{
Console.WriteLine(t);
}
Console.WriteLine("---");
}
I think I'd rather define a class to hold my const strings and use a method to iterrate, though.
|
|
|
|
|
Using reflection:
List<string> list = new List<string>();
FieldInfo[] fis = type.GetFields(BindingFlags.Public | BindingFlags.Static | BindingFlags.FlattenHierarchy);
foreach (FieldInfo fi in fis)
{
if (fi.IsLiteral && !fi.IsInitOnly)
list.Add(fi.Name);
}
return list;
"WPF has many lovers. It's a veritable porn star!" - Josh Smith As Braveheart once said, "You can take our freedom but you'll never take our Hobnobs!" - Martin Hughes.
My blog | My articles | MoXAML PowerToys | Onyx
|
|
|
|
|
Thanks Pete,
that's what I'm looking for. It works fine.
Ariadne
|
|
|
|
|
HI,
I'm not sure if exist something like ConstantCollection, but this works for me (VB.net):
Firts a simple class:
Public Class Class1
Public Const c1 As String = "c1"
Public Const c2 As String = "c2"
Const c3 As String = "c3"
Dim var1 As String
Public var2 As String
Public Enum myEnum
value1
value2
End Enum
End Class
For Each field As FieldInfo In getConstants(GetType(Class1))
Console.WriteLine(field.Name)
Next
Private Function getConstants(ByVal pType As System.Type) As List(Of System.Reflection.FieldInfo)
Dim fis() As FieldInfo
Dim result As New List(Of System.Reflection.FieldInfo)
fis = pType.GetFields()
For Each fi As FieldInfo In fis
If fi.IsLiteral And Not fi.IsInitOnly Then
result.Add(fi)
End If
Next
Return result
End Function
This returns:
c1
c2
The constants must be declared public.
RolCr.
|
|
|
|
|
Hi,
I'm accessing files from remote PC (basically in from different domain) in Windows Service. During debug (when i put break point and debug through line by line) it goes well, but in deployment mode it throws following error
"Bad user name or password"
How to fix this?
Thanks
|
|
|
|
|
Hi,
Verifie the "Log on" Tab for the service, which account are you using?
|
|
|
|
|
Hi
im trying to implement a calendar interface in my C# application but im not sure what the best way to draw the calendar is - i had a look at the form controls in visual C# 2005 and thought the datagridview might be a good start then populate it with events from an Xml file
Another possible solution would be google calender but i couldnt find any help with drawing google calender in C# application and thier tutorial was about adding and manipultaing events using .NET cliet libraries.
Does anyone have any ideas for this? i would appreciate any help
Cheers
|
|
|
|
|
The DateTimePicker control does it all for you presuming your working with WinForms and not WebForms.
Regards,
Rob Philpott.
|
|
|
|
|
Thanks for the reply, Rob. this is not what i im looking for though. i want to draw a calendar for a schedule and to have the days of the week displayed vertically and the time horizontally (similar to school timetable format) and then to populate this with shifts created in the program.
|
|
|
|
|
Personally I would handle the paint event for a panel and draw with the Graphics class, that way I can make it look anyway I want it to
Life goes very fast. Tomorrow, today is already yesterday.
|
|
|
|
|
A bit like Outlooks Calendar feature? Sorry, got the wrong end of the stick. Two routes to what you want - either get a 3rd party control which does that sort of thing or roll your own.
If you've not written a control like that before, its not a light undertaking!
Regards,
Rob Philpott.
|
|
|
|
|
what do you mean by third party control? something like Google calendar API
Cheers
|
|
|
|
|
You might want to have a look at:
Month Calendar[^]
and maybe:
Calendar DayView Control[^]
as well. There are demos and source code you can download and tweak should you wish.
Hope this helps, and good luck.
|
|
|
|
|
hi guys
i am having trouble formating my string text for my listbox.
this is what i am using
String.Format("{0,-15} \t {1,-50} \t {2,-20} \t", data1,data2,data3);
however due to the amount of space some text used up when many words are used the tab always goes out of place and end up making untidy
does anyone have a better alternative or a solution for this problem? pls assist
|
|
|
|
|
Try a fixed-size font (e.g. Courier) and fill it up with spaces instead of tabs
Doesn't look to cool, I know. If you want something better looking, try the DataGridView or the ListView .
I are troll
|
|
|
|
|
Hi,
I need to plot the Square Wave form which have X and Y- Axis. The Wave will get Plot in to the graph(Windows Form) using c#.
Thanks
With Reg,
Palanivel
|
|
|
|
|
I think you need to be a bit more specific here? How is your wave represented? As a frequency, a wavelength, an array of samples?
Are you just trying to plot it to the screen?
Regards,
Rob Philpott.
|
|
|
|
|
Thanks for your quick response Rob!!!
Yes the wave can be drawn from the Array of values and the possible values are follows;
- Along the X-Axis (1,2,3,4,....) Y-Axis(A, B, C, D...)
- Based upon the bit values like 010101010 it should come up with UP(1)/DOWN(0) for A in Y-Axis.
It would be helpful if you shown me how to plot the value for Single Y-Axis 'A' Row.
Thanks,
Palanivel
|
|
|
|
|
Okidoke, you don't need to worry about the X-Axis, this just always increments. So you've got an array of booleans which alter (which is pointless really as we can draw a square wave by appreciating its repeating manner).
Graphics wise you'll want a windows forms application. Derive a class from Panel. In the derived classes override OnPaint.
You get a Graphics object given to you by that which allows you to draw lines and such things.
Create the loop and draw the lines. I can't offer much more help without knowing about things like frequency, scaling etc.
Regards,
Rob Philpott.
|
|
|
|
|
Thanks Rob!!!
Your valuable points helpful to achieve the task.
|
|
|
|