|
I want to add a column to my data grid for a treeview structure; where every cell in the column would be a TreeNode object. I wrote a class DataGridTreeNodeColumn that overrides DataGridColumnStyle but you can't just draw a single TreeNode. You have to add the TreeNode to the TreeView and use the TreeView to draw it.
Is it even possible to put a treeview inside a datagrid using this method? Is there another way of doing it? Are there any tutorials that explain how to do this? Thanks in advance.
|
|
|
|
|
Hi
Is there a event which fires when any text gets in to the textbox, either i type or copy paste. I know its possible in keypress and mousedown events but i want a single event where i can identify when a text gets into a textbox. plz do reply if its possible or not.
Cheers!
Cheetu
|
|
|
|
|
|
Hi everyone,
I am just wondering how I can start/restart SQL Server 2000 instance or MSDE programmatically through C#? Does Microsoft have those built-in API?
Cheers!
|
|
|
|
|
|
How can I define a struct like this in C/C++
struct XXX
{
byte b[5];
}
I did it like this
struct XXX
{
byte[5] b; // compile error CS0650
}
another question: how to get component offset in the structure. like in C
int offset = offset(XXX.b);
|
|
|
|
|
You're in the C# forum, you need the C++ forum.
A struct is just a class that defaults to public access ( unlike in C# ). Did byte b[5] cause an error ? My C++ is too rusty for me to answer without checking, but the C++ forum has lots of people who can help.
BTW, a struct is just a class with default access of public. In C#, it's a whole different story.
Christian
I have several lifelong friends that are New Yorkers but I have always gravitated toward the weirdo's. - Richard Stringer
|
|
|
|
|
I'm sorry. I think I should clarify my question. My question is about C#, I want to define a byte array in a structure ( a user defined data type ). This can be easily done in C/C++ like
struct abc
{
byte b[5];
}
My question is may I define a structure in C#, which contains a byte array? similar to about example.
Thank u for your input.
|
|
|
|
|
public struct XXX
{
byte [] xx;
}
Your problem is that a struct cannot have a parameterless constructor, so you can only provide constructors that set this value by passing it in. However, you CAN add a property, which could be:
byte [] xx
{
set
{
System.Diagnostics.Debug.Assert(value.Length <= 5, "XXX.xx must be an array of 5 bytes or less");
etc.
Or you could be nice and just copy the first 5 bytes of a larger array, it depends what the struct value really is, and what is valid behaviour for your situation. Half a comment may be OK, half an IP address probably isn't.
Christian
I have several lifelong friends that are New Yorkers but I have always gravitated toward the weirdo's. - Richard Stringer
|
|
|
|
|
It also depends on whether he needs to match a struct (e.g. return values) or if he simply wants to use it internally.
In the latter case, he could simply use an object instead, which would allow him to use parameterless constructors.
Cheers
Sid
|
|
|
|
|
How can I define a struct like this in C/C++
struct XXX
{
byte b[5];
}
[StructLayout(LayoutKind.Sequential)]
public struct XXX
{
[MarshalAs(UnmanagedType.ByValArray, SizeConst=5)]
public byte[] b;
}
This assumes that you want to pass the struct to an unmanaged function.
If you don't want to pass the struct to an unmanaged function take a look at the last example in this article - Using Structs in C#[^]
another question: how to get component offset in the structure. like in C
int offset = offset(XXX.b);
I don't think its possible with C#
"I think I speak on behalf of everyone here when I say huh?" - Buffy
|
|
|
|
|
I'm trying to locate the VS.Net icons used for their drop down smartthingy.
I'm writing a pluggin, and was hoping to use the icons as displaying all the class types etc, in text, is becoming a major chore.
How can this be done? Prefferably without breaching any copywrite laws etc.
Cheers guys
Cat
|
|
|
|
|
I dont know whether it will breach the copyright law or not. The icons have been in the assembly itself as a resource. You can use the tools like .NET Reflector to see the icons. An easy way, make a screenshot and cut it from it
|
|
|
|
|
I have a control inherited from a combo box. I noticed that any properties I set in it's constructor are overridden by any property settings made in the windows forms designer because they are applied after the object is constructed.
I want to ensure that any properties I set within the control are not overriden in the form designer, (or can be if I choose depending upon where they are set).
Problem is that I can't tell which event is the best place to put this kind of stuff in. There is no equivalent of LoadForm for a control that I know of. I'm wondering if there is a generally accepted best event to set control properties in?
|
|
|
|
|
For the record, here is the solution:
The trick is to separate the running of the constructor in design time versus run time.
There is a designtime property but it will not work for this purpose as it is always null in the constructor, either of the following *do* work:
<br />
if(System.Diagnostics.Process.GetCurrentProcess().ProcessName != "devenv")<br />
<br />
<br />
if(LicenseManager.UsageMode == LicenseUsageMode.Designtime)
|
|
|
|
|
In my main App I run a long running process on a seperate thread so as not to tie up the GUI - while the process is running I want to set the Cursor to the WaitCursor. The first thing the long running process does it fire an event which is handled on the GU thread and sets the cursor to the WaitCursor then when the process has finished it fires another event which is again handled on the GUI thread and sets the Cursor to default - however, the cursor never actually changes to the WaitCursor
The long running process fires off an event every 1000 records or so which is handled on the GU thread thus:
<br />
Private Delegate Sub xxxDelegate(ByVal sender As Object, ByVal e As xxxEventArgs)<br />
<br />
Private Sub xxx(ByVal sender As Object, ByVal e As xxxEventArgs) Handles LongProcess.xxx<br />
<br />
If button.InvokeRequired = False Then<br />
Console.WriteLine("A - " & Cursor.Current.ToString())<br />
...<br />
Else<br />
Console.WriteLine("B - " & Cursor.Current.ToString())<br />
Dim del As New xxxDelegate(AddressOf xxx)<br />
Me.BeginInvoke(del, New Object() {sender, e})<br />
End If<br />
End Sub<br />
When run the following is written to the console:
B - [Cursor: WaitCursor]
A - [Cursor: Default]
B - [Cursor: WaitCursor]
A - [Cursor: Default]
B - [Cursor: WaitCursor]
A - [Cursor: Default]
...
Why is this?
|
|
|
|
|
this is definitely the c# forum.
|
|
|
|
|
Whoops, sorry about that - my apps engine is in C# and the GUI is in VB (don't ask) and I tend to spend more time on the C# messageboard - I guess I got bit carried away
|
|
|
|
|
hi, I need a regular expression to replace / with // in a richTextBox1. how is this done? I have this:
string replace_1 = Regex.Replace(richTextBox1.Text, @"/", @"//");
but it doesn't replace the string with the replacement string in the richTextBox1. can you show me something that would work? thanks in advance,
Stephen
|
|
|
|
|
Why do you need a regex here ? The string class is well able to do this for you.
Christian
I have several lifelong friends that are New Yorkers but I have always gravitated toward the weirdo's. - Richard Stringer
|
|
|
|
|
can you show me what the code would look like. I tried this:
<br />
string replace_1 = richTextBox1.Text;<br />
replace_1.Replace("/", "//");<br />
richTextBox1.Text = "";<br />
richTextBox1.Text = replace_1;<br />
but no luck.
|
|
|
|
|
Have you looked in the debugger ? I think the rich text box is your problem.
Christian
I have several lifelong friends that are New Yorkers but I have always gravitated toward the weirdo's. - Richard Stringer
|
|
|
|
|
RichTextBox1.Text.Replace(@"/", @"//");
You're going to run into a problem each time you run this though. Every time you run this, or any other similar function, you'll end up doubling the number of slash marks EVERY time it's run. So...
/ This is a test...
will become
will become
will become
Unless you put in some code that checks for this condition...
RageInTheMachine9532
"...a pungent, ghastly, stinky piece of cheese!" -- The Roaming Gnome
|
|
|
|
|
I'm having horrible luck with this. i made a simple simple app with one regular textBox1, and a button. on the button's click I have this code:
textBox1.Text.Replace(@"/", @"//");
just like you showed me. it still won't work (I also tried it with the richTextBox, and still no luck. I'm so annoyed at this. It's plagueing me. any ideas? thanks
|
|
|
|
|
Try this
str="aa/aaa/aaa/"
str1=""
Iterate each character in str
{
if TheCharacter =="/"
str1+="/"
str1+=TheCharacter
}
<italic>Work hard, Work effectively and a bit of luck is the key to success.
|
|
|
|