|
how do i bind a listbox to an xml file then how do i read that xml file in another form
the last part i can probably figure out but binding it to xml file is killing me
Thanks
Da Intern
|
|
|
|
|
I'm not sure if that is possible. Parse the xml file and use the YourList.Items.Add method. Also, I'm not sure what you mean by "xml file in another form". if it is some sort of object you can either make it public, make a property or create a method in the "OtherForm" that allows access to the file.
Goodluck
|
|
|
|
|
|
Uh i still need some more help
Da Intern
|
|
|
|
|
|
What I am trying to do is to insert a new DataRow at a specific location in the DataRowCollection. I know that the order of items may not be preserved when using Select or GetChildRows method, but according to the DataRowCollection.InsertAt documentation, this order IS preserved when writing the data as XML (using the DataSet.WriteXml method). But it is not Imagine the following scenario:
1. The DataSet is populated using the ReadXml method
2. A newly created row is inserted at the beginning of the DataRowCollection using the dt.Rows.InsertAt(dr, 0);
3. The DataTable dt is data bound to a DataGrid control, without any sorting, (the newly inserted row is indeed displayed as the first record).
4. The whole dataset is written to an XML file, using the DataSet's WriteXml method. And, surprise, the newly created row is at the END of the table
What am I doing wrong? Anyone ever experienced this? Any clues or ideas are highly appreciated.
Rado
|
|
|
|
|
I don't know, it should work, but the following code is an alternative:
BackColor.GetBrightness();
BackColor.GetHue();
BackColor.GetSaturation();
So, you don't need to resort to interop.
Acting as a substitute for God, he becomes a dispenser of justice. - Alexandre Dumas
|
|
|
|
|
|
|
WiB wrote:
"...hasn't really been well accepted ... as the ratings tell us so far " - Nishant S
Just curious - what's your reason for quoting this?
"Blessed are the peacemakers, for they shall be called sons of God." - Jesus
"You must be the change you wish to see in the world." - Mahatma Gandhi
|
|
|
|
|
jdunlap wrote:
Just curious - what's your reason for quoting this?
Hey, she needs to quote something, right?
Acting as a substitute for God, he becomes a dispenser of justice. - Alexandre Dumas
|
|
|
|
|
I tried using this code :
if ((Control.ModifierKeys & Keys.LShiftKey) == Keys.LShiftKey)
and a few other combinations but it doesn't work. I can detect just the shift key being pressed but i want to detect if the LEFT shift key (which is more specific) being pressed. Is there any way?
|
|
|
|
|
both shift keys ( the one on the left of the keyboard and the one on the right ) hold the same value "16" so no way to tell , but if you wish to catch events such as the up / down arrows etc... you can do something like this :
C#:
<font color="blue">private</font> <font color="blue">void</font> Form1_Load(<font color="blue">object</font> sender, System.EventArgs e) <br> { <br> <font color="#0000FF">this</font>.KeyPreview=<font color="#0000FF">true</font>; <br> } <br><font color="DarkGreen">
hope it helps.
Vb:
<font color="blue">Public Function</font> TwinsOnWay(<font color="blue">ByVal</font> twins <font color="blue">As String</font>) <font color="blue">As String <br> Select Case</font> twins<br> <font color="blue">Case</font> "Gender" <br> <font color="blue">Return</font> "Two Girls" <br> <font color="blue">End Select <br> End Function</font> <br>
|
|
|
|
|
I have three time values and they are in string format.
string time1 = "12:00:00"
string time2 = "12:30:00"
string time3 = "13:00:00"
time2 changes, but time1 and time3 stay the same
How can I check to see if time2 is between time1 and time3?
I have thought of several different ways but they are all lengthy and involved. I though maybe something like this would work but want to make sure it will always work.
if(time1 <= time2 <= time3)
{
do such -n- such
}
will this work for strings
|
|
|
|
|
draco_iii wrote:
if(time1 <= time2 <= time3)
{
The comparison of time1 <= time 2 returns a bool (if a comparable type, more on that shortly) which it would then compare that bool value to time3.
It would be
time2 >= time1 && time2 <= time3
But there is another problem, you cannot use that as comparisons for strings. You would use the string.CompareTo() with returns a int value:
< 0 : string less than target
0 : same
> 0 : target less than string
So you would have:
if( time2.CompareTo(time1) >= 0 && time2.CompareTo(time3) <= 0)
{
do...
}
Rocky Moore <><
|
|
|
|
|
I use HashTable to store some information retreived from database. In database data is stored in some particular order, that is important for the application.
When I want to display the data (loaded into hashtable) in ASPX page, user gets data _not_ in the same order as it was in the database. Is there any way to force Hashtable to return elements (via iterators) in the same order as entered [Maybe to implement some interface or sth..?]. Or maybe there is another, similar class, holding key-value pairs, that would do this for me.
Thanx for any suggestions
|
|
|
|
|
Why not stick with a DataSet or DataTable in memory, this way you could use a DataView to deal with your sorting. These structures were designed to stay up in memory anyway.
Cheers,;P
Erick
|
|
|
|
|
If for some reason you do not want to use a DataSet or DataTable as the other poster mentioned, you will have to use a combination collection. I had the same problem and solved it by deriving from an ArrayList and a private Hash table. I overrode the Add, Remove and Clear methods to allow be to handle both arrays. On the Add, I would call a base Add on the collection and then call a hash add with my key and the poistion of the object in the ArrayList. The this[] indexer I added with a string (mine was a text value for the key) and did a find using the hash and returned the reference from the base ArrayList by the index pulled from the hash table.
This allowed me to use the foreach on the collection to retrieve them in the order I placed them in the list but still allowed my fast access to an individual value based on the key.
Is simple to build and easy to use!
Rocky Moore <><
|
|
|
|
|
The HashTable is the wrong data container for that kind of functionality, as you've discovered.
In essence, for the HashTable to provide access to its items in constant time--the major advantage to hash tables--it stores them in a kind of hash code order, not in "alphabetic" order (which has a logarithmic access time) or arrival time order (which is linear in time).
Hence when you list the items in a hash table you get them in this bizarre ultra funky order.
Cheers, Julian
Program Manager, C#
This posting is provided "AS IS" with no warranties, and confers no rights.
|
|
|
|
|
Hi All,
I am using GetProcesses API to enumrate all the processes on windows. Using EnableRaisingEvents , I am trapping the Exit event through my delegator.
but Somtimes it works and some times it not. I do not know y it is so..
The code Snippet is as follows:
Process []_WorkStationProcesses= Process.GetProcesses();
for(Index =0; Index < _WorkStationProcesses.Length;Index++)
{
if(_WorkStationProcesses[Index].ProcessName=="Idle")
continue;
_WorkStationProcesses[Index].EnableRaisingEvents=true;
_WorkStationProcesses[Index].Exited+= new EventHandler(new _ProcessExitDelegator(_ProcessExit));
}
then the delegator
public delegate void _ProcessExitDelegator(Object sender, EventArgs e);
void _ProcessExit(Object sender, EventArgs e){
MessageBox.Show(((Process)sender).ProcessName + " Exited");
}
VikramS
|
|
|
|
|
The problem is that your application doesn't have enough rights to access all the processes. Even if this code is run from admin.
For example system procs, when you try to kill them from the task manager some will fail.
|
|
|
|
|
So how i will able to gets those access rights or at least monitor the processes that are not system related.
|
|
|
|
|
I have....
form1.cs and log.cs
on log.cs there is a list box, listBox1 .
now, in log.cs I write to it as follows...
listBox1.Items.Add("HI");
but, now... I want to be on form1.cs and be able to write to listBox1 , which is on log.cs...
How do I do this?
/\ |_ E X E GG
|
|
|
|
|
First, form1.cs needs a reference to log.cs (you probably already have done this):
log objLog = new log();
Next, you need a public or internal accessor for the ListBox in log.cs:
public System.Windows.Forms.ListBox LogListBox<br />
{<br />
get { return this.listBox1; }<br />
}
Now you can add items to the log.cs ListBox from within form1.cs like this:
objLog.LogListBox.Items.Add("Hi");
|
|
|
|
|
haha... no.
how do I refrence to log.cs?
/\ |_ E X E GG
|
|
|
|