|
Good day.
In my app have ListBox and i items draged.How to know Drag&Drop to Windows Explorer ?
My draged items size will be very big , like 4,5 GB, so i can't use MemoryStream.
Please help me.
Thanks .We are haven't bug,just temporarily undecided problems.
|
|
|
|
|
Hello Friends,
i want to get the client browser time on server side. I am developing an application in C# and i want to display some alerts according to client machine time. So please let me know if there is any way in which i can get it on server side code.
Thanks
Sher Azam
|
|
|
|
|
Read the client time using javascript, put it in a hidden field, post the form.
|
|
|
|
|
Thanks for your reply.
can you please provide me sample code for it?
actually i try this method but when i get the hidden field on server side it came empty.
a sample code will be very helpful for me.
|
|
|
|
|
|
Hey guys, I'm trying to create a regular expression which matches text with html links in it. I want to extract both the URL and the 'clickable' text. The regular expression so far :
(<a(.)*href=("|')(?<url>(.)*)("|')(.)*>(?<text>(.)+)</a>)
Now in general, this works. When I enter a text with a html link in it :
blah blah blah <a href="/link.aspx" target="_blank">clickable text</a> blah blah
The regular expression returns one match containing <a href... ... </a> so that works fine...
However, when I enter a text that contains two links :
blah blah blah <a href="/link.aspx" target="_blank">clickable text</a> blah blah blah blah blah <a href="/link.aspx" target="_blank">clickable text</a> blah blah
The regular expression still returns one match, containing the first <a href... till the second </a> which is not the wanted result. I want the regular expression to return two matches. Can anyone help me?
Regex regx = new Regex("<a(.)*href=(\"|')(?<url>(.)*)(\"|')(.)*>(?<text>(.)+)</a>", RegexOptions.IgnoreCase | RegexOptions.Multiline | RegexOptions.Compiled);
MatchCollection col = regx.Matches(Input);
|
|
|
|
|
Try this tool, Expresso[^]. It has a library of regex and testing environment that may help I know the language. I've read a book. - _Madmatt
|
|
|
|
|
I am familiar with Expresso, which by the way returns the same result. Expresso also returns only one match containing the tag opening of the first link, untill the closure of the second link. I want two matches with both links
Thanks for the help anyway
|
|
|
|
|
I think your problem is that . is greedy. You should make it lazy with ? . (Reference[^])
This <a(.)*?href=(\"|')(?<url>(.)*?)(\"|')(.)*?>(?<text>(.)+?)</a> should work. Although it is untested.
Lazy lookup is less efficient than regular lookup so you may want to use something more appropriate like (?<url>[^'"]*) .
I have found http://www.regular-expressions.info/[^] to be a great resource.
|
|
|
|
|
Wow, works flawless! You for presedent!!
Thanks !
|
|
|
|
|
Hi everyone.
I'm creating a class through reflection and I'd like to have a static initializer like this:
class MyClass {
static MyClass() {
someMethod(typeof(MyClass));
}
}
That is, I'd like to obtain the type of MyClass and pass it to someMethod as argument. What's giving me trouble is obtaining the type of MyClass , since I'm emitting this code before the type MyClass is created: I'm defining MyClass with a TypeBuilder , but I haven't called CreateType() yet because I first need to add the static initializer. I have a hen-and-egg situation here.
Ideally what I'd like is to do something like:
class MyClass {
static MyClass() {
someMethod(this.GetType());
}
}
but of course not with this because I'm in a static member and there's no "this". So, is there something equivalent to this but that identifies the class (or type) in which the code is declared (i.e., to which class belongs the code that is being run)? Sorry if I don't make much sense, I'm having trouble expressing this clearly
Thanks!modified on Friday, February 19, 2010 8:35 AM
|
|
|
|
|
blackblizzard wrote: someMethod(this.GetType());
Try this.
someMethod(typeof(MyClass)); Me, I'm dishonest. And a dishonest man you can always trust to be dishonest. Honestly. It's the honest ones you want to watch out for...
|
|
|
|
|
|
No, sorry, the problem is I'm emitting the code with Reflection.Emit, so I can't just type "MyClass".
It works like this:
* Someone calls my class ObjectFactory with a Type they want me to extend, say "MyType".
* Using reflection, I create a subclass of MyType, called EXT_MyType, which has some extra fields and methods. I want to add a static initializer to EXT_MyType, which should look like this:
static EXT_MyType() {
someMethod(typeof(EXT_MyType));
}
But the problem is when I emit the code for this static initializer I haven't yet created the type EXT_MyType (that's what I'm doing, I'm creating its static initializer, etc), so I don't know how to emit this code. See, I'm trying to emit it like this:
ilGenerator.Emit(OpCodes.Ldtoken, typeof(EXT_MyType));
ilGenerator.Emit(OpCodes.Call, typeof(EXT_MyType).GetMethod("someMethod"));
but EXT_MyType doesn't exist yet. So I'm wondering whether there's a primitive or something I can invoke from within the static initializer that will allow me to do this instead:
static EXT_MyType() {
someMethod(getTypeOfThisClass());
}
Where getTypeOfThisClass() would be that "primitive or something...". Since this call would take place once I've created EXT_MyType there wouldn't be a problem. I just don't know whether a primitive like that exists.
If it doesn't, I'd appreciate suggestions on alternative ways of doing this.
Thanks!
|
|
|
|
|
There's no such primitive. You'll have to emit a typeof(EXT_MyType).
This doesn't mean that typeof(EXT_MyType) has to appear in your code - you can get the System.Type instance in other ways using the Reflection API.
In fact, I think you already are using that System.Type instance: System.Reflection.Emit.TypeBuilder derives from System.Type.
So you should be able to use:
ilGenerator.Emit(OpCodes.Ldtoken, myTypeBuilder);
|
|
|
|
|
Yeah, thanks, I think that's it. I had actually found a solution:
ilGenerator.Emit(OpCodes.Ldtoken, classInitializer.DeclaringType);
but of course yours is better, since there's no point doing it like that when I already have the type builder. It was a newbie question
Thanks!
(I was going to post my own solution but I'm still having some (hopefully unrelated) issues, so I was waiting to see if it really did solve the problem; I'll mark the thread as solved, though)
EDIT: It worked! Thanks
|
|
|
|
|
Hi experts
i am working with winform using C#.NET
Can you Help Me that if i am Create ADO.NET Connection
like
using(SqlConnection ICon=new new SqlConnection()
{
ICon.Open();
}
if i am using this connection in 100 form then i have every time open that connection in every form or any other way to manage this.
dinesh
|
|
|
|
|
Sharma Dinesh Kumar wrote: if i am using this connection in 100 form then i have every time open that connection in every form or any other way to manage this.
..or you create a small method that gives you an new and open connection;
SqlConnection GimmeConnection()
{
SqlConnection con = new SqlConnection(connectionString);
con.Open;
return con;
} ..used like this;
Using (SqlConnection = GimmeConnection)
{
} I are Troll
|
|
|
|
|
Hi everyone.
I'm having trouble with the following: I need a way to distinguish the different fields of a class by means of integers -- for example, given the following class:
class MyClass {<br />
<br />
float floatField;<br />
double[] arrayField;<br />
Object objectField;<br />
<br />
}
I'd like to be able to identify floatField as field 0, arrayField as field 1, and objectField as field 2. I don't really care about the order, but I need the integers to be consecutive and to never change throughout execution. They can change between executions.
I haven't seen any straightforward method for this in Type . The best I can come up with is to call typeof(MyClass).GetFields() and use the order the fields in the return array as their id. For example, if it returns [floatField, arrayField, objectField] , it would return in the ids I mentioned above (0, 1 and 2, respectively).
I'm going to need to find the id of a given field pretty often throughout execution, so I create a dictionary that maps the name of a field to its index, like so:
int i = 0;
Dictionary<string, int> fieldOffsetDict = new Dictionary<string, int>();
foreach (FieldInfo field in typeof(MyClass).GetFields(BindingFlags.Instance | BindingFlags.Static | BindingFlags.NonPublic | BindingFlags.Public)) {
fieldOffsetDict[field.Name] = i++;
}
Anyone can think of a better way of doing this (for example, is there a method that I've failed to see that would do this directly), or do I keep it as it is? I can't help but feel this is a bit of an overkill, so I'd like to make sure.
Also, if I didn't mind the ids not being consecutive, would there be a better way to do this?
Thanks.
|
|
|
|
|
Hi,
if you want a free choice for the field names, and need name->ID mapping, the dictionary seems best; for a simple ID->name mapping, a List would suffice.
if you don't really care about field names, then why not name them consecutively, hence:
class MyClass {
float f0;
double[] f1;
Object f2;
}
Luc Pattyn [Forum Guidelines] [Why QA sucks] [My Articles]
I only read code that is properly formatted, adding PRE tags is the easiest way to obtain that. All Toronto weekends should be extremely wet until we get it automated in regular forums, not just QA.
|
|
|
|
|
Thanks for the confirmation.
I do care about field names, just not about their order. The code still needs to be legible
|
|
|
|
|
Hello!
I have a problem with some WPF controls.
For example I created a derived from Window tooltip, that will display the .xaml instance of MenuButtons. MenuButtons just simply containts 2 buttons that can be clicked by the user. That's the code :
(menuContentTooltip is a class derived from Window, and that will contain my WPF .xaml MenuButtons control, this menuContentTooltip is a global variable)
if (menuContentTooltip != null)
{
menuContentTooltip.Close();
menuContentTooltip = null;
}
MenuButtons menuButtons = new MenuButtons();
var ttp = new ToolTipParams
{
ParentFrameworkEl = menuBtn,
ChildControlInToolTip = menuButtons,
Title = "Menu",
PositionOfToolTip = ToolTipParams.Position.Below
};
menuContentTooltip = new ToolTip(ttp, false, null);
if (menuContentTooltip.ChildControl != null)
{
((MenuButtons) menuContentTooltip.ChildControl).DemmarerButton.MouseLeftButtonUp += delegate
{
if (menuContentTooltip != null)
menuContentTooltip.Close();
};
((MenuButtons) menuContentTooltip.ChildControl).GestionButton.MouseLeftButtonUp += delegate
{
if (menuContentTooltip != null)
menuContentTooltip.Close();
};
menuContentTooltip.ShowToolTipIfNotAuto();
}
The problem is that everytime when I click the button that executes the code above, the application memory increases without reason, and if I do memory dumping, loading SOS.dll, I see more and more objects of MenuButtons type. For example I clicked and closed the tooltip 3 times, then in visual studio I see this:
!dumpheap -mt 036424f0
Address MT Size
0eabe738 036424f0 264
0ec03568 036424f0 264
0ed03fe0 036424f0 264
total 3 objects
Statistics:
MT Count TotalSize Class Name
036424f0 3 792 MenuButtons
Total 3 objects
!gcroot 0eabe738
Note: Roots found on stacks may be false positives. Run "!help gcroot" for
more info.
Error during command: Warning. Extension is using a callback which Visual Studio does not implement.
Scan Thread 3692 OSTHread e6c
Scan Thread 820 OSTHread 334
Scan Thread 4040 OSTHread fc8
Scan Thread 1804 OSTHread 70c
Scan Thread 2780 OSTHread adc
Scan Thread 3128 OSTHread c38
Scan Thread 3352 OSTHread d18
Scan Thread 2388 OSTHread 954
Scan Thread 3260 OSTHread cbc
Scan Thread 3908 OSTHread f44
Scan Thread 1264 OSTHread 4f0
Scan Thread 2516 OSTHread 9d4
Scan Thread 2760 OSTHread ac8
Scan Thread 2828 OSTHread b0c
Scan Thread 1816 OSTHread 718
Scan Thread 2500 OSTHread 9c4
Scan Thread 3156 OSTHread c54
Scan Thread 1424 OSTHread 590
Scan Thread 2680 OSTHread a78
Scan Thread 2900 OSTHread b54
Scan Thread 4004 OSTHread fa4
Scan Thread 3668 OSTHread e54
Scan Thread 3032 OSTHread bd8
Scan Thread 2536 OSTHread 9e8
Scan Thread 2580 OSTHread a14
Scan Thread 436 OSTHread 1b4
Scan Thread 2040 OSTHread 7f8
Scan Thread 1912 OSTHread 778
Scan Thread 2540 OSTHread 9ec
Scan Thread 1916 OSTHread 77c
DOMAIN(0015DB80):HANDLE(WeakSh):963878:Root:0ebc0514(System.EventHandler)->
0ebc0250(System.Windows.Documents.AdornerLayer)->
0ebc0158(System.Windows.Documents.AdornerDecorator)->
0ebc054c(System.Windows.Controls.ContentPresenter)->
0eb639c4(System.Windows.Controls.Grid)->
0eb63b08(System.Windows.Controls.UIElementCollection)->
0eb63b1c(System.Windows.Media.VisualCollection)->
0eb67a58(System.Object[])->
0eb67948(System.Windows.Controls.Grid)->
0eb67ac4(System.Windows.Controls.UIElementCollection)->
0eb67ad8(System.Windows.Media.VisualCollection)->
0eb67bf8(System.Object[])->
0eb67af0(System.Windows.Controls.StackPanel)->
0eb67ee8(System.Windows.Controls.UIElementCollection)->
0eb67efc(System.Windows.Media.VisualCollection)->
0ebbf5e8(System.Object[])->
0eabe738(MenuButtons)
!gcroot 0ec03568
Note: Roots found on stacks may be false positives. Run "!help gcroot" for
more info.
Error during command: Warning. Extension is using a callback which Visual Studio does not implement.
Scan Thread 3692 OSTHread e6c
Scan Thread 820 OSTHread 334
Scan Thread 4040 OSTHread fc8
Scan Thread 1804 OSTHread 70c
Scan Thread 2780 OSTHread adc
Scan Thread 3128 OSTHread c38
Scan Thread 3352 OSTHread d18
Scan Thread 2388 OSTHread 954
Scan Thread 3260 OSTHread cbc
Scan Thread 3908 OSTHread f44
Scan Thread 1264 OSTHread 4f0
Scan Thread 2516 OSTHread 9d4
Scan Thread 2760 OSTHread ac8
Scan Thread 2828 OSTHread b0c
Scan Thread 1816 OSTHread 718
Scan Thread 2500 OSTHread 9c4
Scan Thread 3156 OSTHread c54
Scan Thread 1424 OSTHread 590
Scan Thread 2680 OSTHread a78
Scan Thread 2900 OSTHread b54
Scan Thread 4004 OSTHread fa4
Scan Thread 3668 OSTHread e54
Scan Thread 3032 OSTHread bd8
Scan Thread 2536 OSTHread 9e8
Scan Thread 2580 OSTHread a14
Scan Thread 436 OSTHread 1b4
Scan Thread 2040 OSTHread 7f8
Scan Thread 1912 OSTHread 778
Scan Thread 2540 OSTHread 9ec
Scan Thread 1916 OSTHread 77c
Scan Thread 3812 OSTHread ee4
Scan Thread 1244 OSTHread 4dc
Scan Thread 2740 OSTHread ab4
Scan Thread 3808 OSTHread ee0
Scan Thread 536 OSTHread 218
Scan Thread 3148 OSTHread c4c
Scan Thread 2908 OSTHread b5c
Scan Thread 3436 OSTHread d6c
Scan Thread 3236 OSTHread ca4
Scan Thread 4044 OSTHread fcc
Scan Thread 3780 OSTHread ec4
Scan Thread 1352 OSTHread 548
Scan Thread 1140 OSTHread 474
Scan Thread 604 OSTHread 25c
DOMAIN(0015DB80):HANDLE(WeakSh):96387c:Root:0ece0858(System.EventHandler)->
0ece0594(System.Windows.Documents.AdornerLayer)->
0ece049c(System.Windows.Documents.AdornerDecorator)->
0ece0890(System.Windows.Controls.ContentPresenter)->
0ec96634(System.Windows.Controls.Grid)->
0ec96778(System.Windows.Controls.UIElementCollection)->
0ec9678c(System.Windows.Media.VisualCollection)->
0ec9a6c8(System.Object[])->
0ec9a5b8(System.Windows.Controls.Grid)->
0ec9a734(System.Windows.Controls.UIElementCollection)->
0ec9a748(System.Windows.Media.VisualCollection)->
0ec9a868(System.Object[])->
0ec9a760(System.Windows.Controls.StackPanel)->
0ec9ab58(System.Windows.Controls.UIElementCollection)->
0ec9ab6c(System.Windows.Media.VisualCollection)->
0ecdffc4(System.Object[])->
0ec03568(MenuButtons)
!gcroot 0ed03fe0
Note: Roots found on stacks may be false positives. Run "!help gcroot" for
more info.
Error during command: Warning. Extension is using a callback which Visual Studio does not implement.
Scan Thread 3692 OSTHread e6c
Scan Thread 820 OSTHread 334
Scan Thread 4040 OSTHread fc8
Scan Thread 1804 OSTHread 70c
Scan Thread 2780 OSTHread adc
Scan Thread 3128 OSTHread c38
Scan Thread 3352 OSTHread d18
Scan Thread 2388 OSTHread 954
Scan Thread 3260 OSTHread cbc
Scan Thread 3908 OSTHread f44
Scan Thread 1264 OSTHread 4f0
Scan Thread 2516 OSTHread 9d4
Scan Thread 2760 OSTHread ac8
Scan Thread 2828 OSTHread b0c
Scan Thread 1816 OSTHread 718
Scan Thread 2500 OSTHread 9c4
Scan Thread 3156 OSTHread c54
Scan Thread 1424 OSTHread 590
Scan Thread 2680 OSTHread a78
Scan Thread 2900 OSTHread b54
Scan Thread 4004 OSTHread fa4
Scan Thread 3668 OSTHread e54
Scan Thread 3032 OSTHread bd8
Scan Thread 2536 OSTHread 9e8
Scan Thread 2580 OSTHread a14
Scan Thread 436 OSTHread 1b4
Scan Thread 2040 OSTHread 7f8
Scan Thread 1912 OSTHread 778
Scan Thread 2540 OSTHread 9ec
Scan Thread 1916 OSTHread 77c
Scan Thread 3812 OSTHread ee4
Scan Thread 1244 OSTHread 4dc
Scan Thread 2740 OSTHread ab4
Scan Thread 3808 OSTHread ee0
Scan Thread 536 OSTHread 218
Scan Thread 3148 OSTHread c4c
Scan Thread 2908 OSTHread b5c
Scan Thread 3436 OSTHread d6c
Scan Thread 3236 OSTHread ca4
Scan Thread 4044 OSTHread fcc
Scan Thread 3780 OSTHread ec4
Scan Thread 1352 OSTHread 548
Scan Thread 1140 OSTHread 474
Scan Thread 604 OSTHread 25c
DOMAIN(0015DB80):HANDLE(Pinned):9613fc:Root:02331010(System.Object[])->
0ed8dbf0(UserControls.ToolTip)->
0ed03fe0(MenuButtons)
DOMAIN(0015DB80):HANDLE(WeakSh):963880:Root:0ede4040(System.EventHandler)->
0ede3d7c(System.Windows.Documents.AdornerLayer)->
0ed8dbf0(UserControls.ToolTip)
DOMAIN(0015DB80):HANDLE(WeakSh):9613fc:Root:02331010(System.Object[])->
0ed8dbf0(UserControls.ToolTip)
DOMAIN(0015DB80):HANDLE(WeakSh):963880:Root:0ede4040(System.EventHandler)->
0ede3d7c(System.Windows.Documents.AdornerLayer)
DOMAIN(0015DB80):HANDLE(WeakSh):9613fc:Root:02331010(System.Object[])->
0ede3d7c(System.Windows.Documents.AdornerLayer)
DOMAIN(0015DB80):HANDLE(WeakSh):963880:Root:0ede4040(System.EventHandler)->
0ede3d7c(System.Windows.Documents.AdornerLayer)
DOMAIN(0015DB80):HANDLE(WeakSh):9613fc:Root:02331010(System.Object[])->
0ede3d7c(System.Windows.Documents.AdornerLayer)
DOMAIN(0015DB80):HANDLE(WeakSh):963880:Root:0ede4040(System.EventHandler)->
0ede3d7c(System.Windows.Documents.AdornerLayer)
DOMAIN(0015DB80):HANDLE(WeakSh):9613fc:Root:02331010(System.Object[])->
0ede3d7c(System.Windows.Documents.AdornerLayer)
DOMAIN(0015DB80):HANDLE(WeakSh):963880:Root:0ede4040(System.EventHandler)->
0ede3d7c(System.Windows.Documents.AdornerLayer)
What's wrong with this code, can someone explain and help me?
Thank's in advance!modified on Saturday, February 20, 2010 12:18 PM
|
|
|
|
|
This is C# forum. Here on codeproject there is also forum for WPF
As i know about C# and windows form, the only whay to get memory leak is not to dispose unmanaged resources. Image class is such thing. And it would help if you use <pre></pre> tags around code, so that we can see it nicly formated
|
|
|
|
|
hei,
I want to copy one grid view row to other gv. Is there any shorter way like
gv2.rows.add(gv1.rows[1]);
Syed Shahid Hussain
|
|
|
|
|
|
Hi,
I have a datagridview upon which I allow the user to re-order the columns. I then store the column order in a sqlServer database table. When the user starts the datagridview my code reads the database and retreives the user's column positions.
The code loops through the columns and sets the displayIndex as previously saved. No problems except the columns are displayed in the wrong order The effect is rather inconsistent and not all the columns are in the wrong order.
Under the debugger I can see the displayindices are correctly set as per the database table. The columns just appear in the wrong place on-screen
I have a fix I simply run the code that sets the displayIndices twice. The problem goes away (well up to now).
I wonder if anyone has had similar displayIndex problems and has a better fix? I have one or two comments in my code saying //DONT REMOVE THIS CODE. IT LOOKS WRONG BUT IS FIXING AN ISSUE.
Terry
|
|
|
|
|