|
You could extend the DataGridColumnStyle with your own class that uses a RichTextBox . Override GetMinimumHeight and return an int large enough to show a decent amount of rich text. There are a couple articles here on CodeProject about creating your own DataGridColumnStyle s; just do a search for "DataGridColumnStyle".
Microsoft MVP, Visual C#
My Articles
|
|
|
|
|
i want to implement a simple software firewall by csharp with ability of filtering ip addresses and blocking som of ports
i havent found yet any usefull solution
koosha
|
|
|
|
|
C# is probably a bit high level for that kind of thing. Usually firewalls are implemented deep in OS.
However, a product like WinPKFilter[^] could help as it performs the hooks into the NDIS layer and you can use P/Invoke to process the packets in C#.
Does this help?
"You can have everything in life you want if you will just help enough other people get what they want." --Zig Ziglar
The Second EuroCPian Event will be in Brussels on the 4th of September
|
|
|
|
|
I think this site maybe lead you to a wonder:
Full firewall source code, please visit: http://www.filseclab.com/eng/products/sourcecode.htm.
|
|
|
|
|
How is this much different from using the NDIS Hook code availble in WinPKFilter that I mentioned?
The source you site is written in C/C++ and would still require pinvoking for it to work with .NET.
"You can have everything in life you want if you will just help enough other people get what they want." --Zig Ziglar
The Second EuroCPian Event will be in Brussels on the 4th of September
Can't manage to P/Invoke that Win32 API in .NET? Why not do interop the wiki way!
My Blog
|
|
|
|
|
Hello,
I have a xml-file that looks like this,
<packageimplementation version="1.0">
<companydependancies>
<main>
<tablegroups>
<tablegroup name ="programs">independent</tablegroup>
<tablegroup name ="parameters">independent</tablegroup>
</tablegroups>
</main>
<exeptions company="RLS">
<tablegroups>
<extablegroup name = "settings">independent</extablegroup>
</tablegroups>
<tables>
<extable name ="progmst">independent</extable>
</tables>
</exeptions>
</companydependancies>
</packageimplementation>
Now i wanted to show the tablegroups and the extables in a datagrid, i do it like this:
DataSet ds = new DataSet();
ds.ReadXml(filePath);
dataGrid1.DataSource = ds;
dataGrid1.DataMember = "tablegroup";
DataSet ds2 = new DataSet();
ds2.ReadXml(filePath);
dataGrid2.DataSource = ds2;
dataGrid2.DataMember = "extable";
But this doens't work:
An unhandled exception of type 'System.ArgumentException' occurred in system.data.dll
Additional information: The same table (tablegroups) cannot be the child table in two nested relations.
Why is this wrong and what can i do about it?
Thx in advance
|
|
|
|
|
Hi,
I noticed a problem in the XML which will not allow it to load into the dataset.
the problem is the node "tablegroups" is child of both "main" and "exceptions". So for the dataset to work you need to change one of the name... say "tablegroups_main" and "tablegroups_exp"
regards,
Aryadip.
Cheers !! and have a Funky day !!
|
|
|
|
|
hai there
i have a horscroll bar and a vertical on my form. user may clck once or twice or n number of continues time with out releasing the mouse( click and hold);
i need to cancel all click event and i need to take the last click event.
that is if he click and hold the mouse i need to find the last click value and no of click made on that holding process.
how it is possible
hai, enjoy coding
Sreejith SS Nair
|
|
|
|
|
You should override the WndProc method and handle the WM_HSCROLL (0x0114) and WM_VSCROLL (0x0115). In those cases, if you don't want the scroll operation to occur, do not call base.WndProc . The scroll events will never get to the scroll bar, so it shouldn't scroll.
Microsoft MVP, Visual C#
My Articles
|
|
|
|
|
Hi, while writing a .NET port of my HTML Reader Class Library[^] using C#, I'm kinda stucked with a stupid problem. You may be knowing that the library allows to read HTML text both from in-memory strings and disk files. At first I declared a private field of type System.IO.TextReader in my LiteHTMLReader class (the main class of the library) and defined a Read function with 1 overload. Some portion of the class looked like this:
public class LiteHTMLReader
{
private System.IO.TextReader oHtmlReader = null;
public long Read(string htmlText)
{
oHtmlReader = new StringReader(htmlText);
return (parseHTMLDocument());
}
public long Read(string pathToFile, System.Text.Encoding encoding)
{
oHtmlReader = new StreamReader(pathToFile, encoding, true);
return (parseHTMLDocument());
}
}
But soon enough, I learned that readers (derived from System.IO.TextReader ) are just forward-only. But sometimes while parsing an HTML document, I need to move back also. So, I rejected the idea of using readers. So obviously, my next option was using streams. Ok now we have a System.IO.FileStream class to deal with files, but what about the string s.
- How can I open a stream on a string?
- Is there any class available in the framework?
- Shall I go for my own implementation?
- Any other better option availble for the above-defined scenario?
Please suggest.
Even if I use streams, there is one more thing I need to know. Stream s deal with bytes only (GetBytes ). String class uses Unicode by default. How to deal with this situation?
Guys, I'm so sorry for asking soooooo much but you can obviosly guess that I'm a newbie in C#. And I'm getting mails daily from different people requesting me to release a .NET port of the library. Please help.
Any suggestions are welcome.
Regards,
Gurmeet BTW, can Google help me search my lost pajamas?
My Articles: HTML Reader C++ Class Library, Numeric Edit Control
|
|
|
|
|
xsl transform to stream adds extra characters
That question indicates you can use MemoryStream for string streams. Hope that helps.
regards,
Paul Watson
Bluegrass
South Africa
Chris Maunder wrote:
"I'd rather cover myself in honey and lie on an ant's nest than commit myself to it publicly."
Jon Sagara replied:
"I think we've all been in that situation before."
Crikey! ain't life grand?
|
|
|
|
|
... but I'm not sure if its the right one. Now my class looks like this:
public class LiteHTMLReader
{
private System.IO.Stream oHtmlStream;
public long Read(string htmlText)
{
using (this.oHtmlStream = new System.IO.MemoryStream(System.Text.Encoding.Unicode.GetBytes(htmlText)))
{
long lCharCount = this.parseHTMLDocument();
return (lCharCount);
}
}
public long ReadFile(string pathToFile)
{
using (System.IO.StreamReader sr = new System.IO.StreamReader(pathToFile, true))
{
string strFileData = sr.ReadToEnd();
return (this.Read(strFileData));
}
}
} I dunno why but I dont think this is the actual way to do it. Can someone clear my doubts?
Heath Stewart, Mike Dimmick, any other C# guru, where are you guyz? Please help.
Thanks,
Gurmeet BTW, can Google help me search my lost pajamas?
My Articles: HTML Reader C++ Class Library, Numeric Edit Control
|
|
|
|
|
You can use the Encoding class to convert the bytes to strings using the appropriate encoding.
Also, even with a reader, you should be able to call Seek on the BaseStream property if you use a StreamReader (which derives from TextReader ).
Microsoft MVP, Visual C#
My Articles
|
|
|
|
|
If you do Seek on the BaseStream , remember to call DiscardBufferedData on the StreamReader . Otherwise, you'll get the rest of the buffered data before you get the data from the new position in the stream.
It doesn't look like you can turn this buffering off.
Stability. What an interesting concept. -- Chris Maunder
|
|
|
|
|
Your solution suggests using BaseStream, property of StreamReader class. But I don't only need to deal with files, I need to deal with strings also. The StreamReader class has a BaseStream property but the StringReader class does not. What do you suggest in this case?
Moreover, I would like to ask you whether the "alternate way" that I've posted above is right according to you in this situation or not.
Thanks,
Gurmeet BTW, can Google help me search my lost pajamas?
My Articles: HTML Reader C++ Class Library, Numeric Edit Control
|
|
|
|
|
There's almost never a "right" way, just good and bad ways. Your alternative - if it works - isn't bad and seems to be pretty efficient. That's what counts.
Microsoft MVP, Visual C#
My Articles
|
|
|
|
|
|
Sorry, that was supposed to be "efficient", not "inefficient" ( I use the latter far more often here in this forum ). Context clues should've told you that, but thanks for the low vote anyway.
Microsoft MVP, Visual C#
My Articles
|
|
|
|
|
Can i create a split window with the LHS consisting of various tabs and on the RHS have buttons that will jump to different tabs? How would I go about doing this?
|
|
|
|
|
Hi,
you can change the tabs on the fly by handling the button click event. In the delegate you need to write :
TabControl1.SelectedIndex = 0;
and that will do the magic...
Note : the int value starts from 0.give the index of the tab you want to select. There is another property SelectedTab. If you have the indivisual tab objects , you can use them.
regards,
aryadip.
Cheers !! and have a Funky day !!
|
|
|
|
|
IS there a way of converting a struct to an byte array.
My struct has two fields an int in the form of an enum and a string
thestruct
{
enum_Do_something; // goes to a switch case with a list of commans.
string command; // what to do
}
is there a way to just convert this to an byte array? or should i just send each field. This is for a server/client apps.
modified 16-May-21 21:01pm.
|
|
|
|
|
If both the client and server are .NET applications, you could always use a BinaryFormatter (or any formatter, using the proper Encoding class if using text I/O) which would be much easier. You could just write to the NetworkStream for the TcpClient , for example, using this method.
One way is a bit of a hack, but should work:
int size = Marshal.SizeOf(typeof(thestruct));
IntPtr ptr = Marshal.AllocHGlobal(int);
byte[] buffer = new byte[size];
Marshal.Copy(ptr, buffer, 0, size);
Marshal.FreeHGlobal(ptr);
Microsoft MVP, Visual C#
My Articles
|
|
|
|
|
My connection is between a OC and a pocket PC, so im using the .Net Compact framework, i should have posted that.
Well then i got the thinking, pulling weird stuff out of my head, "what if i cast the struct to an object and send the object.ToSting() ?, no that will never work"
But i still tried it, so i just threw something together:
aStruct qwerty = new aStruct( 35, "Football");
object wed = (object) qwerty;
aStruct ytrewq = ( aStruct ) wed;
Console.WriteLine( ytrewq.aInt.ToString() );
out of dumb luck it worked, strange. Well is this way bad? i havent tried to send it yet (ByteArrayData = Encoding.ASCII.GetBytes( wed.ToString()), but it worked.
modified 16-May-21 21:01pm.
|
|
|
|
|
i go ahead of myself ( i do that alot) yea the above code works but not the .ToString i should have known that
modified 16-May-21 21:01pm.
|
|
|
|
|
No, that's not a good way because you can't as easily parse the string back into a struct. ToString overrides are meant to represent an instance of a class or struct. Some classes won't output near enough information to reconstitute it, and any struct that overrides ToString (I do it quite a bit) won't have enough information either.
Since you're using the .NET CF (which would've been nice to know before writing all that stuff that isn't supported in it ), you're definitely in a bind - but not an impossible solution (I don't know the meaning of it...just improbable solutions ).
The best way is to do basically what a formatter would do - use reflection to get the public and private fields of a structure. It you don't have any nested compex types, this is pretty much all you'd have to do. Then, for each type check if it has a TypeConverter using TypeDescriptor.GetConverter and call ConvertToString on that. That will often give a more accurate representation as a string, and ConvertFromString can reconstitute the member Type. Be careful, though - while most types you'd typically find in a struct have a TypeConverter , many types throughout the .NET Framework don't.
See the TypeConverter and TypeDescriptor class documentation in the .NET Framework SDK for more information.
Microsoft MVP, Visual C#
My Articles
|
|
|
|