|
Create it in another thread it will do that jop
|
|
|
|
|
Hi experts,
I am trying to display data in a datagrid from a xml file. I have no problem reading the xml file, however when i try to display the data in a datagrid all i get is "null" values. I have bound my dataset to the datasource property but still dont know where im going wrong
can anyone point me in the right direction???
Cheers
|
|
|
|
|
A simple example:
DataSet ds = new DataSet();<br />
ds.ReadXml("99999.xml");<br />
<br />
this.dataGrid1.DataSource = ds.Tables[0].DefaultView;<br />
<br />
CurrencyManager cm = (CurrencyManager)this.BindingContext[this.dataGrid1.DataSource, this.dataGrid1.DataMember]; <br />
((DataView)cm.List).AllowNew = false;<br />
<br />
this.dataGrid1.CaptionText = "Total Tasks: " + dataGrid1.BindingContext[dataGrid1.DataSource, dataGrid1.DataMember].Count.ToString();
Hope this helps
Regards,
Polis
Can you practice what you teach?
|
|
|
|
|
I want to get the value(the X and Y value)of a curve from a .jpg file?
get the value of the curve from a .jpg file.
could anyone give me a sample about it?
my E-mail: dxhdxh2k@hotmail.coom
Thanks
|
|
|
|
|
How many times are you going to ask this question ? I've answered it several times, you obviously just want someone to write code for you. I suggest going to rentacoder if you want some cheap code to do this. It might even work.
Christian
I have several lifelong friends that are New Yorkers but I have always gravitated toward the weirdo's. - Richard Stringer
|
|
|
|
|
My aim is to use the above specified classes for encryption and decryption on strings send across the network.
I am unable to find how to use these two classes put together.
Can anyone help me in this regard. Early response is encouraged.
|
|
|
|
|
Hi,
1) Create the key and IV
2) Create a crypto service provider
3) Create a crypto stream
4) Create new stream writer on the crypto stream
byte [] key ={171, 196, 154, 92, 35, 195, 212, 50};
byte [] IV ={65, 86, 22, 91, 214, 4, 177, 199};
try
{
DESCryptoServiceProvider dsp = new DESCryptoServiceProvider();
MemoryStream ms = new MemoryStream();
CryptoStream cs = new CryptoStream(ms,dsp.CreateEncryptor(key,IV),CryptoStreamMode.Write);
StreamWriter sw = new StreamWriter(cs);
sw.Write(textBox1.Text);
sw.Flush();
cs.FlushFinalBlock();
ms.Flush();
textBox2.Text = Convert.ToBase64String(ms.GetBuffer(),0, (int)(ms.Length));
}
catch(Exception ex)
{
MessageBox.Show(ex.ToString());
}
Hope this will help you.
Thanks and Regards
SGS
|
|
|
|
|
I am intereseted in developing network application where a server and client will just pass the text messages. I am using Tcp sockets. I could not incorporate networkstream classes in the context. I mean to say that I have to work with networkstream, streamwriter or streamreader and cryptostream classes put together.
Hope you understand the situation.
|
|
|
|
|
Hi there..
There is a lot of examples on how to do the server client stuff in the .Net framework documentation. Search for "TCP" and you'll get something usefull! About the cryptographic stuff:
<br />
public string Encrypt(string ToCrypt)<br />
{<br />
string encoded = "";<br />
byte [] EncKey = {0x16, 0x1F, 0x01, 0x03, 0x1A, 0x0B, 0x10, 0x7F, 0x65, 0x5E, 0x45, 0x3F, 0x11,0x1F, 0xFF, 0xEF, 0x32, 0xEE, 0x5F, 0x38, 0xA7, 0xB2, 0xCC, 0x77, 0x51, 0x14, 0x40, 0x8A, 0x95, 0xE5, 0x00, 0x84};<br />
<br />
byte [] EncIV = {0x05, 0x14, 0x06, 0x15, 0x02, 0x13, 0x00, 0x0F, 0xC0, 0xD8, 0xB6, 0x58, 0xE4, 0xA9, 0x21, 0x5E};<br />
<br />
RijndaelManaged rmEnc = new RijndaelManaged();<br />
rmEnc.Key = EncKey;<br />
rmEnc.IV = EncIV;<br />
<br />
StreamWriter sw = new StreamWriter(encoded);<br />
CryptoStream cs = new CryptoStream(sw, rmEnc.CreateEncryptor(rmEnc.Key, rmEnc.IV), <br />
CryptoStreamMode.Write);<br />
cs.Write(Encoding.ASCII.GetBytes(ToCrypt), 0, ToCrypt.Length);<br />
<br />
cs.Close();<br />
sw.Close();<br />
<br />
return encoded;<br />
}<br />
If this wasen't what you were looking for, you must express yourself more clearly. What is the exact problem?
|
|
|
|
|
Hi Aijaz,
You can initialize the crypto stream class using any class that's derieved from Stream class. (Ex File Stream , Memory Stream, NetworkStream).
Using NetworkStream:
TcpClient client = new TcpClient();
NetworkStream ns = client.GetStream();
CryptoStream cs = new CryptoStream(ns,dsp.CreateEncryptor(key,IV),CryptoStreamMode.Write);
StreamWriter sw = new StreamWriter(cs);
Guess this will help you.
Thanks and Regards
SGS
|
|
|
|
|
Hi All,
I need to export the Chartfx graph which is displayed on a webpage to an excel document(as a graph itself) .How can it be done using C# code??
Can anyone help me out ??
Thanks ,
Sunil
|
|
|
|
|
ChartFX renders and image in ASP.NET, and is nothing like the OLE Chart object that you can embed into Excel. It's simply an image. You could automate downloading and adding the ChartFX-rendered image into Excel, but it won't update when you change data in the worksheet like I'm sure you'd want to happen.
What you need is the data that was used to generate the chart for ChartFX. You could expose this through an XML web service, which Excel could pretty easily import into a worksheet (see the Excel help topics for how to import XML data from a web service, which is outside the scope of this forum) and have an OLE Chart object already embedded.
This posting is provided "AS IS" with no warranties, and confers no rights.
Software Design Engineer
Developer Division Customer Product-lifecycle Experience
Microsoft
[My Articles] [My Blog]
|
|
|
|
|
WOW, it's Heath Stewart! Haven't seen you around in a while. How are things going at Microsoft?
/\ |_ E X E GG
|
|
|
|
|
I know how to sync the status bar with the coping or some things,
But, any body knows how to do it with a web browser control with loading the web page on custom code ?
I've tried many but ...?
Any ideas ?.
|
|
|
|
|
LongHC wrote:
...with a web browser control with loading the web page on custom code?
What do u mean by custom code?
There are some interesting things u can do with the System.Net namespaces, e.g. u could have a streamreader accosiated to a WebRequest/WebResponse containing the characters of the webpage you are trying to load and have the progress bar progressing after each character is being read from the streamreader.
Have a look
here[^]
Regards,
Polis
Can you practice what you teach?
|
|
|
|
|
I have a word search program.
Each letter in a UserControl.
I want to draw with GDI over the controls to circle words and what not.
Any ideas or links.
Nick
I'm not an expert yet, but I play one at work. Yeah and here too.
|
|
|
|
|
Simply use this.CreateGraphics.(any method you want);
is will be helpful to you,if that is what i exepect
|
|
|
|
|
actually its a bad idea to just create a graphics object. muck like putting an include directive on every file in an MFC application. It upsets the architecture in place.
But I cant draw over the controls still.
my existing code is:
public void frmMain_Paint( object sender, System.Windows.Forms.PaintEventArgs e )
{
//e.Graphics.FillRectangle(new Pen(Brushes.AliceBlue, 2), 50,50,800,800);
e.Graphics.FillRectangle(Brushes.Aqua, 50,50,800,800);
}
which accomplishes the same thing.
But, alas it still doesnt work. I know GDI and directx. Its not the issue,itsw how I either make the control transparent or find a way to bring the grahics to the top.
Nick
I'm not an expert yet, but I play one at work. Yeah and here too.
|
|
|
|
|
But, alas it still doesnt work. I know GDI and directx. Its not the issue,itsw how I either make the control transparent or find a way to bring the grahics to the top.
yeah I tried this before ,
just make the FillRectangle(Brushes.FromArgb(128,Color.Aqua));
as this number stands to the transparency.
|
|
|
|
|
thanks man
I'm not an expert yet, but I play one at work. Yeah and here too.
|
|
|
|
|
:->
|
|
|
|
|
Here's my code:
<br />
foreach(GameRoom gr in Room)<br />
{<br />
if (gr.Name.ToLower() == Name.ToLower())<br />
{<br />
return "roomexists";<br />
}<br />
}<br />
"Room" is a hashtable of GameRoom objects. "gr.Name" and "Name" are string values. When this routine is run, and there are more than zero elements in the Room hashtable, I get an Invalid Cast Exception. Being an intermediate programmer, I'm not sure what that means, or exactly why it's being caused.
Any insights?
Thanks for your help.
|
|
|
|
|
foreach in C# compiles to using a collections IEnumerable implementation, where IEnumeration.Current returns an object that (hopefully) casts correctly to whatever type you specify. With a Hashtable , however, foreach compiles to use the Hashtable.GetEnumerator method which returns an IDictionaryEnumerator , where IDictionaryEnumerator.Current returns an IDictionaryEntry , not object . Depending on whether your Game object exists in the key or value of the hashtable, you use IDictionaryEntry.Key or IDictionaryEntry.Value and cast that to your GameRoom type.
You can also use foreach (GameRoom gr in Room.Keys) or foreach (GameRoom gr in Room.Values ) depending on whether your object is in the key or value of the hashtable.
I must say you're going about this wrong, however. The reason for using a hashtable is fast lookups, typically on the order of O(1), where your enumeration will be O(n), which is much slower.
For each GameRoom , you should add it and the name with the name as the key and the GameRoom as the value. If you use a case-insentive hash code provider and comparer, you don't have to worry about casing, like in the following example:
Hashtable rooms = new Hashtable(
new CaseInsensitiveHashCodeProvider(),
new CaseInsensitiveComparer();
rooms.Add(gr1.Name, gr1);
rooms.Add(gr2.Name, gr2); Now when you need to get a specific GameRoom , just do something like this:
return rooms["GameRoom1"] as GameRoom; If you want to see if the GameRoom exists, use Hashtable.Contains("GameRoom1") , which is an O(1) operation since it uses the hash code of the name to find the key immediately if available.
This posting is provided "AS IS" with no warranties, and confers no rights.
Software Design Engineer
Developer Division Customer Product-lifecycle Experience
Microsoft
[My Articles] [My Blog]
|
|
|
|
|
I meant to add that you can learn a lot about your assemblies - and solve problems like this - by using ildasm.exe that ships with the .NET Framework SDK, which is installed by default with Visual Studio and downloadable separately from http://msdn.microsoft.com/netframework[^]. Finding the method in the tree and looking at the implementation would've reveals something like the following example I threw together quickly (does nothing):
.method private hidebysig instance void Example() cil managed
{
.maxstack 2
.locals init (valuetype [mscorlib]System.Collections.DictionaryEntry V_0,
class [mscorlib]System.Collections.IDictionaryEnumerator V_1,
class [mscorlib]System.IDisposable V_2)
IL_0000: ldarg.0
IL_0001: ldfld class [mscorlib]System.Collections.Hashtable Test::table
"color: rgba(255, 0, 0, 1)"> IL_0006: callvirt instance class [mscorlib]System.Collections.IDictionaryEnumerator [mscorlib]System.Collections.Hashtable::GetEnumerator()
IL_000b: stloc.1
.try
{
IL_000c: br.s IL_0029
IL_000e: ldloc.1
"color: rgba(255, 0, 0, 1)"> IL_000f: callvirt instance object [mscorlib]System.Collections.IEnumerator::get_Current()
IL_0014: unbox [mscorlib]System.Collections.DictionaryEntry
IL_0019: ldobj [mscorlib]System.Collections.DictionaryEntry
IL_001e: stloc.0
IL_001f: ldstr "test"
IL_0024: call void [mscorlib]System.Console::WriteLine(string)
IL_0029: ldloc.1
IL_002a: callvirt instance bool [mscorlib]System.Collections.IEnumerator::MoveNext()
IL_002f: brtrue.s IL_000e
IL_0031: leave.s IL_0044
}
finally
{
IL_0033: ldloc.1
IL_0034: isinst [mscorlib]System.IDisposable
IL_0039: stloc.2
IL_003a: ldloc.2
IL_003b: brfalse.s IL_0043
IL_003d: ldloc.2
IL_003e: callvirt instance void [mscorlib]System.IDisposable::Dispose()
IL_0043: endfinally
}
IL_0044: ret
} This may look difficult at first, but you learn over time (just like programming).
This posting is provided "AS IS" with no warranties, and confers no rights.
Software Design Engineer
Developer Division Customer Product-lifecycle Experience
Microsoft
[My Articles] [My Blog]
|
|
|
|
|
Most helpful, thank you. It's hard to overstate how beneficial people like you are to us frustrated, fledgling programmers.
|
|
|
|
|