qid
int64
4
8.14M
question
stringlengths
20
48.3k
answers
list
date
stringlengths
10
10
metadata
list
input
stringlengths
12
45k
output
stringlengths
2
31.8k
540,876
<p>I'm trying to convert a proprietary string mask to the .net equivalent of it. For that I need to exchange every occurance of [someText] with {aDigit}.</p> <pre><code>private static int hits = 0; private static object hitsLock = new object(); public static string ConvertSdsFileMaskToStringMask(string sdsFileMaskStr...
[ { "answer_id": 540886, "author": "Philip Reynolds", "author_id": 1087, "author_profile": "https://Stackoverflow.com/users/1087", "pm_score": 4, "selected": true, "text": "<p>For Ubuntu 8.04 (aka hardy), you need to install the libstdc++6-4.2-dbg package.</p>\n\n<pre><code>$ sudo aptitude...
2009/02/12
[ "https://Stackoverflow.com/questions/540876", "https://Stackoverflow.com", "https://Stackoverflow.com/users/11333/" ]
I'm trying to convert a proprietary string mask to the .net equivalent of it. For that I need to exchange every occurance of [someText] with {aDigit}. ``` private static int hits = 0; private static object hitsLock = new object(); public static string ConvertSdsFileMaskToStringMask(string sdsFileMaskString) { Reg...
For Ubuntu 8.04 (aka hardy), you need to install the libstdc++6-4.2-dbg package. ``` $ sudo aptitude install libstdc++6-4.2-dbg ``` If you need to find files like this in future, install apt-file if it isn't already installed and use apt-file search. ``` $ sudo aptitude install apt-file ... $ sudo apt-file search /...
540,897
<p>I'm using Perl's <a href="http://search.cpan.org/perldoc?XML::Simple" rel="nofollow noreferrer">XML::Simple</a> to parse deeply nested XML and would like to extract a small list of elements about 4 levels down:</p> <pre><code>A B C D1 D2 D3 </code></pre> <p>Ideally I want to do this on the...
[ { "answer_id": 541046, "author": "jrockway", "author_id": 8457, "author_profile": "https://Stackoverflow.com/users/8457", "pm_score": 2, "selected": false, "text": "<p>Assuming your data in memory looks like:</p>\n\n<pre><code>my $parsed = {\n A =&gt; {\n B =&gt; {\n ...
2009/02/12
[ "https://Stackoverflow.com/questions/540897", "https://Stackoverflow.com", "https://Stackoverflow.com/users/52416/" ]
I'm using Perl's [XML::Simple](http://search.cpan.org/perldoc?XML::Simple) to parse deeply nested XML and would like to extract a small list of elements about 4 levels down: ``` A B C D1 D2 D3 ``` Ideally I want to do this on the input step, if possible. Like this: ``` my @list = XMLin($xml...
Thanks for all the suggestions. In the end I ducked the problem of traversing the data structure by using an eval block. ``` my $xml_tree; my @list; eval { # just go for it my @list = @{ $xml_tree->{A}->{B}->{C} }; }; if ($@) { say "oops - xml is not in expected format - and that happens sometimes"; } `...
540,900
<p>When databinding a <code>TreeView</code>, how would you create multiple levels of grouping for the items displayed?</p> <p>Imagine you are binding to a Shop class which, among others, has the properties <code>Region</code> and <code>RetailChain</code>. The desired effect is to have a <code>TreeView</code> that disp...
[ { "answer_id": 541053, "author": "Nir", "author_id": 3509, "author_profile": "https://Stackoverflow.com/users/3509", "pm_score": 0, "selected": false, "text": "<p>You can always write code that will pre-process the data and create a set of classes for easier binding.</p>\n" }, { ...
2009/02/12
[ "https://Stackoverflow.com/questions/540900", "https://Stackoverflow.com", "https://Stackoverflow.com/users/64084/" ]
When databinding a `TreeView`, how would you create multiple levels of grouping for the items displayed? Imagine you are binding to a Shop class which, among others, has the properties `Region` and `RetailChain`. The desired effect is to have a `TreeView` that displays the shops in the following topology: ``` + Regio...
The answer to my problem turned out to be this: Add multiple groupings (via PropertyGroupDescriptor) to the CollectionViewSource, then use a ListBox / DataGrid with multiple GroupStyles. The nett effect of this is that the leaf items (in my example, the stores) are grouped at two distinct levels. Switching which Pro...
540,904
<p>How to prevent a specific key such as backspace key functioning from TextField editable field, preventDefault does not seem to work:</p> <pre><code>public function handleEvents(evt:KeyboardEvent):void { if (evt.type == KeyboardEvent.KEY_UP) { if (evt.keyCode==8){ evt.preventDefault () ; } } </code></pre>
[ { "answer_id": 541002, "author": "Goran", "author_id": 23164, "author_profile": "https://Stackoverflow.com/users/23164", "pm_score": 0, "selected": false, "text": "<p>Try adding evt.stopImmediatePropagation()</p>\n" }, { "answer_id": 541366, "author": "grapefrukt", "autho...
2009/02/12
[ "https://Stackoverflow.com/questions/540904", "https://Stackoverflow.com", "https://Stackoverflow.com/users/20979/" ]
How to prevent a specific key such as backspace key functioning from TextField editable field, preventDefault does not seem to work: ``` public function handleEvents(evt:KeyboardEvent):void { if (evt.type == KeyboardEvent.KEY_UP) { if (evt.keyCode==8){ evt.preventDefault () ; } } ```
I recommend listening for the KEY\_DOWN event if anything, but likely that won't work either. IIRC these type of events are a bit special and you can't really stop them. What I suspect you need to do is to store a copy of the text and whenever you detect a change you don't like just set it back to your stored version.
540,920
<pre><code>#define SAFE_DELETE(a) if( (a) != NULL ) delete (a); (a) = NULL; </code></pre> <p>OR</p> <pre><code>template&lt;typename T&gt; void safe_delete(T*&amp; a) { delete a; a = NULL; } </code></pre> <p>or any other better way</p>
[ { "answer_id": 540929, "author": "gimpf", "author_id": 15529, "author_profile": "https://Stackoverflow.com/users/15529", "pm_score": 3, "selected": false, "text": "<p>Generally, prefer inline functions over macros, as macros don't respect scope, and may conflict with some symbols during ...
2009/02/12
[ "https://Stackoverflow.com/questions/540920", "https://Stackoverflow.com", "https://Stackoverflow.com/users/22076/" ]
``` #define SAFE_DELETE(a) if( (a) != NULL ) delete (a); (a) = NULL; ``` OR ``` template<typename T> void safe_delete(T*& a) { delete a; a = NULL; } ``` or any other better way
Clearly the function, for a simple reason. The macro evaluates its argument multiple times. This can have evil side effects. Also the function can be scoped. Nothing better than that :)
540,922
<p>I'm currently developing an x86 disassembler, and I started disassembling a win32 PE file. Most of the disassembled code looks good, however there are some occurences of the illegal 0xff /7 opcode (/7 means reg=111, 0xff is the opcode group inc/dec/call/callf/jmp/jmpf/push/<em>illegal</em> with operand r/m 16/32). T...
[ { "answer_id": 541010, "author": "Tamas Czinege", "author_id": 8954, "author_profile": "https://Stackoverflow.com/users/8954", "pm_score": 2, "selected": false, "text": "<p>Visual Studio disassembles this to the following:</p>\n\n<pre><code>00417000 FF C7 inc edi \n00...
2009/02/12
[ "https://Stackoverflow.com/questions/540922", "https://Stackoverflow.com", "https://Stackoverflow.com/users/2179300/" ]
I'm currently developing an x86 disassembler, and I started disassembling a win32 PE file. Most of the disassembled code looks good, however there are some occurences of the illegal 0xff /7 opcode (/7 means reg=111, 0xff is the opcode group inc/dec/call/callf/jmp/jmpf/push/*illegal* with operand r/m 16/32). The first g...
Visual Studio disassembles this to the following: ``` 00417000 FF C7 inc edi 00417002 85 78 FF test dword ptr [eax-1],edi 00417005 ?? db ffh 00417006 FF 00 inc dword ptr [eax] ``` Obviously, a general protection fault happens at 004170...
540,926
<p>I am working on a web page which has an iframe and I am loading an external site in the iframe. The page works fine in IE6, FF etc but in IE7 all I see is a blank page. </p> <p>I found that this is due to the phishing filter in IE7. The phishing filter will not be able to check the web page inside the iframe so it ...
[ { "answer_id": 540945, "author": "RuudKok", "author_id": 42142, "author_profile": "https://Stackoverflow.com/users/42142", "pm_score": 2, "selected": false, "text": "<p>Have you set the IFRAME attribute WIDTH? I've read about this before and in those occasions had to do with the 'WIDTH' ...
2009/02/12
[ "https://Stackoverflow.com/questions/540926", "https://Stackoverflow.com", "https://Stackoverflow.com/users/12178/" ]
I am working on a web page which has an iframe and I am loading an external site in the iframe. The page works fine in IE6, FF etc but in IE7 all I see is a blank page. I found that this is due to the phishing filter in IE7. The phishing filter will not be able to check the web page inside the iframe so it will not b...
If you are using **ASP** then add this code ``` Response.AddHeader "p3p", "CP=" & chr(34) & "CURa ADMa DEVa PSAo PSDo OUR BUS UNI PUR INT DEM STA PRE COM NAV OTC NOI DSP COR" & chr(34) ``` in all the pages which are loaded in the **iframe**
540,947
<p>I have a List containing a lot of paths. I have a specific path I want to check against this list to see if there are any paths there that uses this path, ie: </p> <pre><code>f.StartsWith(r.FILENAME) &amp;&amp; f != r.FILENAME </code></pre> <p>What would be the fastest way of doing this? </p> <p>edit: Complete fu...
[ { "answer_id": 540955, "author": "Marc Gravell", "author_id": 23354, "author_profile": "https://Stackoverflow.com/users/23354", "pm_score": 4, "selected": true, "text": "<p>The <em>fastest</em> way is probably with binary search:</p>\n\n<pre><code>static bool ContainsFragment(string[] pa...
2009/02/12
[ "https://Stackoverflow.com/questions/540947", "https://Stackoverflow.com", "https://Stackoverflow.com/users/37083/" ]
I have a List containing a lot of paths. I have a specific path I want to check against this list to see if there are any paths there that uses this path, ie: ``` f.StartsWith(r.FILENAME) && f != r.FILENAME ``` What would be the fastest way of doing this? edit: Complete function from answer below: ``` static boo...
The *fastest* way is probably with binary search: ``` static bool ContainsFragment(string[] paths, string fragment) { // paths **must** be pre-sorted via Array.Sort(paths); if (paths.Length == 0) return false; int index = Array.BinarySearch(paths, fragment); // we want the index of the *next highest* p...
540,969
<p>I'd like to create a WPF control for a window tab, and I want it to have a particular shape. Something like this;</p> <pre><code> +------------------------------+ | | * | | | | +--+ ...
[ { "answer_id": 541036, "author": "Sandeep Datta", "author_id": 39648, "author_profile": "https://Stackoverflow.com/users/39648", "pm_score": 2, "selected": false, "text": "<p>Why not create two different widgets? One for the centre section and another for the stretchable section. Then st...
2009/02/12
[ "https://Stackoverflow.com/questions/540969", "https://Stackoverflow.com", "https://Stackoverflow.com/users/6722/" ]
I'd like to create a WPF control for a window tab, and I want it to have a particular shape. Something like this; ``` +------------------------------+ | | * | | | | +--+ +--+ 6 ...
I did the stretching part in my app by creating a "StretchStackPanel" that inherits from StackPanel. The class looks like this: ``` public class StretchStackPanel : StackPanel { public static DependencyProperty StretchDependencyProperty = DependencyProperty.Register("Stretch", typeof(StretchMode), typeof(StretchSt...
540,970
<p>I believe that local integer variables are not initialized to zero in delphi. The initial value is whatever happens to be at that memory location. So in the code below the first time the button is clicked the first message shows a integer value. How come the second time it's clicked it doesn't show 3 but instead sho...
[ { "answer_id": 540980, "author": "Mark Pim", "author_id": 38883, "author_profile": "https://Stackoverflow.com/users/38883", "pm_score": 3, "selected": false, "text": "<p>Firstly, you're correct that local variables <a href=\"https://stackoverflow.com/questions/132725/are-delphi-variables...
2009/02/12
[ "https://Stackoverflow.com/questions/540970", "https://Stackoverflow.com", "https://Stackoverflow.com/users/6164/" ]
I believe that local integer variables are not initialized to zero in delphi. The initial value is whatever happens to be at that memory location. So in the code below the first time the button is clicked the first message shows a integer value. How come the second time it's clicked it doesn't show 3 but instead shows ...
kjack, It contains whatever value is in the stack frame at that time. In your case, this will be Sender. If you'd take the integer and typecast it to an object you'll notice the "pattern". ``` procedure TForm1.Button1Click(Sender: TObject); var int1 : integer; begin ShowMessage(TObject(int1).ClassName); show...
540,976
<p>I have a very simple piece of code (just for testing):</p> <pre><code>import smtplib import time server = 'smtp.myprovider.com' recipients = ['johndoe@somedomain.com'] sender = 'me@mydomain.com' message = 'Subject: [PGS]: Results\n\nBlaBlaBla' session = smtplib.SMTP(server) session.sendmail(sender,recipients,mes...
[ { "answer_id": 541003, "author": "dF.", "author_id": 3002, "author_profile": "https://Stackoverflow.com/users/3002", "pm_score": 5, "selected": true, "text": "<p><code>smtplib</code> doesn't automatically include a <code>From:</code> header, so you have to put one in yourself:</p>\n\n<pr...
2009/02/12
[ "https://Stackoverflow.com/questions/540976", "https://Stackoverflow.com", "https://Stackoverflow.com/users/28149/" ]
I have a very simple piece of code (just for testing): ``` import smtplib import time server = 'smtp.myprovider.com' recipients = ['johndoe@somedomain.com'] sender = 'me@mydomain.com' message = 'Subject: [PGS]: Results\n\nBlaBlaBla' session = smtplib.SMTP(server) session.sendmail(sender,recipients,message); ``` T...
`smtplib` doesn't automatically include a `From:` header, so you have to put one in yourself: ``` message = 'From: me@example.com\nSubject: [PGS]: Results\n\nBlaBlaBla' ``` (In fact, `smtplib` doesn't include *any* headers automatically, but just sends the text that you give it as a raw message)
540,977
<p>For some of my Dynamic Data meta data tables I would like to control the order of the displayed columns. I have a custom page and I created a sub-directory named the same as my table. I copied the ListDetails.aspx and code file to the new directory. And changed AutoGenerateColumns to false(in Gridview) and AutoGen...
[ { "answer_id": 541003, "author": "dF.", "author_id": 3002, "author_profile": "https://Stackoverflow.com/users/3002", "pm_score": 5, "selected": true, "text": "<p><code>smtplib</code> doesn't automatically include a <code>From:</code> header, so you have to put one in yourself:</p>\n\n<pr...
2009/02/12
[ "https://Stackoverflow.com/questions/540977", "https://Stackoverflow.com", "https://Stackoverflow.com/users/-1/" ]
For some of my Dynamic Data meta data tables I would like to control the order of the displayed columns. I have a custom page and I created a sub-directory named the same as my table. I copied the ListDetails.aspx and code file to the new directory. And changed AutoGenerateColumns to false(in Gridview) and AutoGenerate...
`smtplib` doesn't automatically include a `From:` header, so you have to put one in yourself: ``` message = 'From: me@example.com\nSubject: [PGS]: Results\n\nBlaBlaBla' ``` (In fact, `smtplib` doesn't include *any* headers automatically, but just sends the text that you give it as a raw message)
540,986
<p>I am trying to get the sources for Netbeans IDE by running:</p> <p>hg clone <a href="http://hg.netbeans.org/main/" rel="noreferrer">http://hg.netbeans.org/main/</a></p> <p>However, this seems to be taking forever, and it does not give me any kind of status which tells me the percent of download that's complete. If...
[ { "answer_id": 541007, "author": "VonC", "author_id": 6309, "author_profile": "https://Stackoverflow.com/users/6309", "pm_score": 3, "selected": true, "text": "<p>May be a <a href=\"http://www.selenic.com/mercurial/bts/msg5141\" rel=\"nofollow noreferrer\"><code>clone -verbose</code></a>...
2009/02/12
[ "https://Stackoverflow.com/questions/540986", "https://Stackoverflow.com", "https://Stackoverflow.com/users/34956/" ]
I am trying to get the sources for Netbeans IDE by running: hg clone <http://hg.netbeans.org/main/> However, this seems to be taking forever, and it does not give me any kind of status which tells me the percent of download that's complete. If a lose my internet connection, I have to start all over again. I realize ...
May be a [`clone -verbose`](http://www.selenic.com/mercurial/bts/msg5141) would give you more details about what goes wrong ? ``` C:\netbeans-src>hg clone --verbose http://hg.netbeans.org/main destination directory: main requesting all changes adding changesets adding manifests adding file changes ``` If there is no...
540,996
<p>I am trying to output the timestamp after each step (target). When excuting the below build file by ant testtime i get the output:</p> <pre><code>Buildfile: build.xml testdepend1: [echo] ****** Start: test depend 1 ****** [echo] ****** Finish: test depend 1****** [echo] 02/12/2009 11:58:07 AM testd...
[ { "answer_id": 541025, "author": "VonC", "author_id": 6309, "author_profile": "https://Stackoverflow.com/users/6309", "pm_score": 2, "selected": false, "text": "<p>Once evaluated, TODAY_UK will not be computed again.</p>\n\n<p>May be you should add at the beginning of your task something...
2009/02/12
[ "https://Stackoverflow.com/questions/540996", "https://Stackoverflow.com", "https://Stackoverflow.com/users/-1/" ]
I am trying to output the timestamp after each step (target). When excuting the below build file by ant testtime i get the output: ``` Buildfile: build.xml testdepend1: [echo] ****** Start: test depend 1 ****** [echo] ****** Finish: test depend 1****** [echo] 02/12/2009 11:58:07 AM testdepend2: [...
Once evaluated, TODAY\_UK will not be computed again. May be you should add at the beginning of your task something like: ``` <tstamp> <format property="TODAY_UK" pattern="dd MMM yyyy HH.mm" locale="en_GB" /> </tstamp> <echo message="${TODAY} at ${TSTAMP}" /> ``` Using the Core Task [tstamp](http://ant.apache.or...
540,998
<p>I am learning Objective-C and have hit a snag.</p> <p>I have created a custom object called "Baddie". I am trying to add the object to a couple of mutable arrays.</p> <pre><code>Baddie *b1 = [[Baddie alloc]initWithTag:4444 pos:cpv(450,270) dir:cpv(0,1)]; [baddieArray addObject: b1]; [baddieWaitingArray addObj...
[ { "answer_id": 541025, "author": "VonC", "author_id": 6309, "author_profile": "https://Stackoverflow.com/users/6309", "pm_score": 2, "selected": false, "text": "<p>Once evaluated, TODAY_UK will not be computed again.</p>\n\n<p>May be you should add at the beginning of your task something...
2009/02/12
[ "https://Stackoverflow.com/questions/540998", "https://Stackoverflow.com", "https://Stackoverflow.com/users/29830/" ]
I am learning Objective-C and have hit a snag. I have created a custom object called "Baddie". I am trying to add the object to a couple of mutable arrays. ``` Baddie *b1 = [[Baddie alloc]initWithTag:4444 pos:cpv(450,270) dir:cpv(0,1)]; [baddieArray addObject: b1]; [baddieWaitingArray addObject: [[Baddie alloc]i...
Once evaluated, TODAY\_UK will not be computed again. May be you should add at the beginning of your task something like: ``` <tstamp> <format property="TODAY_UK" pattern="dd MMM yyyy HH.mm" locale="en_GB" /> </tstamp> <echo message="${TODAY} at ${TSTAMP}" /> ``` Using the Core Task [tstamp](http://ant.apache.or...
541,022
<p>Why do I fail to extract an integer value into the <code>Num</code> variable?</p> <pre><code>#include &lt;sstream&gt; #include &lt;vector&gt; #include &lt;iostream&gt; using namespace std; int main() { string Digits("1 2 3"); stringstream ss(Digits); string Temp; vector&lt;string&gt;Tokens; w...
[ { "answer_id": 541029, "author": "Johannes Schaub - litb", "author_id": 34509, "author_profile": "https://Stackoverflow.com/users/34509", "pm_score": 3, "selected": false, "text": "<p>You have to reset all status flags (eofbit) and bring the stream into a good state (goodbit):</p>\n\n<pr...
2009/02/12
[ "https://Stackoverflow.com/questions/541022", "https://Stackoverflow.com", "https://Stackoverflow.com/users/48461/" ]
Why do I fail to extract an integer value into the `Num` variable? ``` #include <sstream> #include <vector> #include <iostream> using namespace std; int main() { string Digits("1 2 3"); stringstream ss(Digits); string Temp; vector<string>Tokens; while(ss >> Temp) Tokens.push_back(Temp); ...
When the stream extracts the last of the 3 digist "1 2 3" the eof state will be set. This is not cleared by the str() member,you need to do it yourself. Change your code to: ``` ss.clear(); ss.str(Tokens[0]); ```
541,024
<p>I have an existing ASP.NET app which is configured to connect to a MS SQL Server database and I am trying to modify it to use a postgres database instead.</p> <p>I would like to avoid modifying the C# code, if possible.</p> <p>I expected that the following changes would be sufficient:</p> <ol> <li>Add a reference...
[ { "answer_id": 541050, "author": "MrTelly", "author_id": 56092, "author_profile": "https://Stackoverflow.com/users/56092", "pm_score": 2, "selected": true, "text": "<p>The rather wonderful <a href=\"http://www.connectionstrings.com/\" rel=\"nofollow noreferrer\">http://www.connectionstri...
2009/02/12
[ "https://Stackoverflow.com/questions/541024", "https://Stackoverflow.com", "https://Stackoverflow.com/users/12048/" ]
I have an existing ASP.NET app which is configured to connect to a MS SQL Server database and I am trying to modify it to use a postgres database instead. I would like to avoid modifying the C# code, if possible. I expected that the following changes would be sufficient: 1. Add a reference to a suitable postgres dri...
The rather wonderful <http://www.connectionstrings.com/> gives examples of all kinds of connection strings, and yours looks to be OK. Unfortunately your code is using SqlClient which is the SqlServer only database access in .Net. You're going to have to hack some code ...
541,061
<p>How do you call a JavaScript function at the end of button click event in code behind?</p>
[ { "answer_id": 541131, "author": "tehvan", "author_id": 61848, "author_profile": "https://Stackoverflow.com/users/61848", "pm_score": -1, "selected": false, "text": "<p>You probably want the onmouseup event:</p>\n\n<pre><code>&lt;button onmouseup=\"alert('You release the mouse button!')\...
2009/02/12
[ "https://Stackoverflow.com/questions/541061", "https://Stackoverflow.com", "https://Stackoverflow.com/users/64104/" ]
How do you call a JavaScript function at the end of button click event in code behind?
If you're working in .NET you could try ``` ScriptManager.RegisterClientScriptBlock(myButton, this.GetType(), "BlockName", "alert('hello world');", true); ```
541,062
<p>I have a problem with the boost::asio::serial_port class reading from a GPS device (USB-Serial). Connecting the device and reading from it works fine, but when I disconnect and reconnect the device, read_some doesn't read any bytes from the port.</p> <p>As boost doesn't seam to detect that the serial port is gone (...
[ { "answer_id": 541097, "author": "Quassnoi", "author_id": 55159, "author_profile": "https://Stackoverflow.com/users/55159", "pm_score": 3, "selected": true, "text": "<p>It's hard to say what is the exact reason in your case, but practice shows that you often need to disable <code>RTS</co...
2009/02/12
[ "https://Stackoverflow.com/questions/541062", "https://Stackoverflow.com", "https://Stackoverflow.com/users/25472/" ]
I have a problem with the boost::asio::serial\_port class reading from a GPS device (USB-Serial). Connecting the device and reading from it works fine, but when I disconnect and reconnect the device, read\_some doesn't read any bytes from the port. As boost doesn't seam to detect that the serial port is gone ( is\_ope...
It's hard to say what is the exact reason in your case, but practice shows that you often need to disable `RTS` sensitivity on your serial port. `RTS` is a pin on real `RS-232` interface that is on when a device on the other side is on. `serial_port::read_some` invokes underlying `Windows API` function that looks on ...
541,078
<p>In my project we have a base exception. For handling showing error dialogs, log and such. Im looking for a way to handle all derived classes of that exception, I thought this would work:</p> <pre><code>try { main_loop(); } catch (const MyExceptionBase* e) { handle_error(e); } </code></pre> <p>As every child in...
[ { "answer_id": 541086, "author": "Evan Teran", "author_id": 13430, "author_profile": "https://Stackoverflow.com/users/13430", "pm_score": 1, "selected": false, "text": "<p>This should work:</p>\n\n<pre><code>try {\n main_loop();\n} catch (const MyExceptionBase &amp;e) {\n handle_error(...
2009/02/12
[ "https://Stackoverflow.com/questions/541078", "https://Stackoverflow.com", "https://Stackoverflow.com/users/56763/" ]
In my project we have a base exception. For handling showing error dialogs, log and such. Im looking for a way to handle all derived classes of that exception, I thought this would work: ``` try { main_loop(); } catch (const MyExceptionBase* e) { handle_error(e); } ``` As every child instance thrown could be rep...
Just mix the two approaches: use the base class, and use a reference. ``` try { main_loop(); } catch (const MyExceptionBase& e) { handle_error(e); } ``` BTW C++ can catch pointers, if you throw them. It's not advisable though.
541,085
<p>Is there a standard function to check that a specified directory is valid?</p> <p>The reason I ask is that I am receiving an absolute directory string and filename from a user and I want to sanity check the location to check that it is valid.</p>
[ { "answer_id": 541095, "author": "xan", "author_id": 15667, "author_profile": "https://Stackoverflow.com/users/15667", "pm_score": 3, "selected": false, "text": "<pre><code>if(System.IO.File.Exists(fileOrDirectoryPath))\n{\n //do stuff\n}\n</code></pre>\n\n<p>This should do the trick!...
2009/02/12
[ "https://Stackoverflow.com/questions/541085", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1816/" ]
Is there a standard function to check that a specified directory is valid? The reason I ask is that I am receiving an absolute directory string and filename from a user and I want to sanity check the location to check that it is valid.
For a file ``` File.Exists(string) ``` For a Directory ``` Directory.Exists(string) ``` *NOTE:* If you are reusing an object you should consider using the FileInfo class vs the static File class. The static methods of the File class does a possible unnecessary security check each time. [FileInfo](http://msdn.m...
541,098
<p>Can I use String.Format() to pad a certain string with arbitrary characters?</p> <pre><code>Console.WriteLine("-&gt;{0,18}&lt;-", "hello"); Console.WriteLine("-&gt;{0,-18}&lt;-", "hello"); returns -&gt; hello&lt;- -&gt;hello &lt;- </code></pre> <p>I now want the spaces to be an arbitrary...
[ { "answer_id": 541136, "author": "configurator", "author_id": 9536, "author_profile": "https://Stackoverflow.com/users/9536", "pm_score": 2, "selected": false, "text": "<p>Edit: I misunderstood your question, I thought you were asking how to pad with spaces.</p>\n\n<p>What you are asking...
2009/02/12
[ "https://Stackoverflow.com/questions/541098", "https://Stackoverflow.com", "https://Stackoverflow.com/users/11333/" ]
Can I use String.Format() to pad a certain string with arbitrary characters? ``` Console.WriteLine("->{0,18}<-", "hello"); Console.WriteLine("->{0,-18}<-", "hello"); returns -> hello<- ->hello <- ``` I now want the spaces to be an arbitrary character. The reason I cannot do it with padLeft...
There is another solution. Implement `IFormatProvider` to return a `ICustomFormatter` that will be passed to string.Format : ``` public class StringPadder : ICustomFormatter { public string Format(string format, object arg, IFormatProvider formatProvider) { // do padding for string arguments // u...
541,100
<p>I'm parsing an xml file using Python's ElementTree, like that: </p> <pre><code>et = ElementTree(file=file("test.xml")) </code></pre> <p>test.xml starts with a few lines of xml comments. </p> <p>Is there a way to get those comments from et?</p>
[ { "answer_id": 541117, "author": "f3lix", "author_id": 60617, "author_profile": "https://Stackoverflow.com/users/60617", "pm_score": 3, "selected": true, "text": "<p>For ElementTree 1.2.X there is an article on <a href=\"http://effbot.org/zone/element-pi.htm\" rel=\"nofollow noreferrer\"...
2009/02/12
[ "https://Stackoverflow.com/questions/541100", "https://Stackoverflow.com", "https://Stackoverflow.com/users/38193/" ]
I'm parsing an xml file using Python's ElementTree, like that: ``` et = ElementTree(file=file("test.xml")) ``` test.xml starts with a few lines of xml comments. Is there a way to get those comments from et?
For ElementTree 1.2.X there is an article on [Reading processing instructions and comments with ElementTree](http://effbot.org/zone/element-pi.htm) (<http://effbot.org/zone/element-pi.htm>). --- *EDIT:* The alternative would be using **lxml.etree** which implements the ElementTree API. A quote from [ElementTree comp...
541,102
<p>Anyone know a better way to do this?</p> <pre><code>Dim Result1,Result2,FinalResult As String Result1 = Left(sXMLResponse, sXMLResponse.IndexOf("&lt;start&gt;")) Result2 = Mid(sXMLResponse, sXMLResponse.IndexOf("&lt;end&gt;")) FinalResult =Result1 &amp; Result2 </code></pre> <p>Surely there is a built in String....
[ { "answer_id": 541151, "author": "Noldorin", "author_id": 44389, "author_profile": "https://Stackoverflow.com/users/44389", "pm_score": 3, "selected": true, "text": "<p>You seem to be doing things in the old VB6 way. It is generally recommended to use the .NET functions in VB.NET, i.e. s...
2009/02/12
[ "https://Stackoverflow.com/questions/541102", "https://Stackoverflow.com", "https://Stackoverflow.com/users/42446/" ]
Anyone know a better way to do this? ``` Dim Result1,Result2,FinalResult As String Result1 = Left(sXMLResponse, sXMLResponse.IndexOf("<start>")) Result2 = Mid(sXMLResponse, sXMLResponse.IndexOf("<end>")) FinalResult =Result1 & Result2 ``` Surely there is a built in String.Remove(StringOne, StringTwo) Method or som...
You seem to be doing things in the old VB6 way. It is generally recommended to use the .NET functions in VB.NET, i.e. string.Substring instead of the Left/Right/Mid/etc. functions. Now it looks like you're simply trying to remove the text between and in a string, which can be done quite easily in one line. ``` Dim res...
541,108
<p>We are gearing up for some pretty serious Sharepoint(MOSS 2007) development including custom web parts, lists, master pages and layouts etc etc and etc.</p> <p>We are evaluating version control and it seems that the discussion has not got much deeper than that. I am keen that we can easily deploy from the source co...
[ { "answer_id": 542654, "author": "Nat", "author_id": 13813, "author_profile": "https://Stackoverflow.com/users/13813", "pm_score": 4, "selected": true, "text": "<p>The closest I have experience is on a project that used <a href=\"http://www.codeplex.com/stsdev\" rel=\"nofollow noreferrer...
2009/02/12
[ "https://Stackoverflow.com/questions/541108", "https://Stackoverflow.com", "https://Stackoverflow.com/users/5552/" ]
We are gearing up for some pretty serious Sharepoint(MOSS 2007) development including custom web parts, lists, master pages and layouts etc etc and etc. We are evaluating version control and it seems that the discussion has not got much deeper than that. I am keen that we can easily deploy from the source control to o...
The closest I have experience is on a project that used [STSDEV](http://www.codeplex.com/stsdev) to build solutions for release. Custom build actions allowed us to remove the sharepoint solution from the target server, install the new solutions and reset the required application pools. Took a while to build, but it wo...
541,123
<p>I need to remove ";" from statements in C which have ";;". Eg:</p> <pre><code>main() { int i;; int j,k;; int l; for(i=0;i&lt;10;;) {} } </code></pre> <p>should become:</p> <pre><code>main() { int i; int j,k; int l; for(i=0;i&lt;10;;) {} } </code></pre>
[ { "answer_id": 541133, "author": "Abgan", "author_id": 46308, "author_profile": "https://Stackoverflow.com/users/46308", "pm_score": 0, "selected": false, "text": "<p>Consider using <strong>Find &amp; replace</strong> command. Any decent text editor has one (Notepad++, KWrite, not to men...
2009/02/12
[ "https://Stackoverflow.com/questions/541123", "https://Stackoverflow.com", "https://Stackoverflow.com/users/65514/" ]
I need to remove ";" from statements in C which have ";;". Eg: ``` main() { int i;; int j,k;; int l; for(i=0;i<10;;) {} } ``` should become: ``` main() { int i; int j,k; int l; for(i=0;i<10;;) {} } ```
UltraEdit could be a good choice..
541,135
<p>How do you bind a DropDownlist DataText or DataValue field from a object. When the object in question is at a second level, e.g. the object to bind is not in the first level of the returned object Users.ContactDetails.Telephone, as the code below doesn't work: </p> <pre><code>ddl.DataSource = dal.dal_Users.GetAllU...
[ { "answer_id": 541261, "author": "Andrew Hare", "author_id": 34211, "author_profile": "https://Stackoverflow.com/users/34211", "pm_score": 3, "selected": false, "text": "<p>If you are using C# 3 then you can use the <code>ConvertAll&lt;&gt;</code> etension method to create a new anonymou...
2009/02/12
[ "https://Stackoverflow.com/questions/541135", "https://Stackoverflow.com", "https://Stackoverflow.com/users/27922/" ]
How do you bind a DropDownlist DataText or DataValue field from a object. When the object in question is at a second level, e.g. the object to bind is not in the first level of the returned object Users.ContactDetails.Telephone, as the code below doesn't work: ``` ddl.DataSource = dal.dal_Users.GetAllUsers(); ddl.Da...
**EDIT:** I got enough feedback about this topic that I felt it was worthy of a [blog post](http://toranbillups.com/blog/archive/2009/06/24/Working-with-a-select-box-using-Model-View-Presenter) One approach that I took when binding domain objects to ddl controls is to inherit from a base class that has an overload in ...
541,167
<p>I am asking this from a language design point of view. So I am trying to find out</p> <ol> <li>What is the rationale for the behavior of <code>this</code>?</li> <li>To what degree the behavior of <code>this</code> was a mistake, or could be improved upon?</li> </ol> <hr> <p>To clarify why I'm uneasy about <code>t...
[ { "answer_id": 541184, "author": "Svante Svenson", "author_id": 19707, "author_profile": "https://Stackoverflow.com/users/19707", "pm_score": 2, "selected": false, "text": "<ul>\n<li>It wasn't</li>\n<li>Lots of OO stuff</li>\n<li>It's good the way it is</li>\n</ul>\n" }, { "answe...
2009/02/12
[ "https://Stackoverflow.com/questions/541167", "https://Stackoverflow.com", "https://Stackoverflow.com/users/53722/" ]
I am asking this from a language design point of view. So I am trying to find out 1. What is the rationale for the behavior of `this`? 2. To what degree the behavior of `this` was a mistake, or could be improved upon? --- To clarify why I'm uneasy about `this`, consider this example: ``` var a = {}; a.f = function(...
You seem to be expecting this to behave as it does in certain OO languages, where it always refers to the object a method belongs to. But in JavaScript, a *function* can be attached to multiple objects, or no object at all. In your example, you've written a function intended to be used in the context of *one specific...
541,169
<p>Could anyone explain to my why this is not working?</p> <p>In the database we have Employees with an IdEmployee column. We also have some tables with foreign keys to that one. </p> <p>Say we have something like this:</p> <pre><code>var employee = dataContext.Employees.First(&lt;some predicate&gt;); var someEntity...
[ { "answer_id": 541176, "author": "thinkbeforecoding", "author_id": 47001, "author_profile": "https://Stackoverflow.com/users/47001", "pm_score": 1, "selected": false, "text": "<p>Edit : the preceding explanation is wrong since 'it works on my machine' :</p>\n\n<pre><code>var contract = d...
2009/02/12
[ "https://Stackoverflow.com/questions/541169", "https://Stackoverflow.com", "https://Stackoverflow.com/users/39321/" ]
Could anyone explain to my why this is not working? In the database we have Employees with an IdEmployee column. We also have some tables with foreign keys to that one. Say we have something like this: ``` var employee = dataContext.Employees.First(<some predicate>); var someEntity = dataContext.SomeEntities.First(...
It is a little bit tricky to know for sure when you have used names like `SomeThings` and `someEntity`, but what I believe is happening is that when you're looking at `someEntity.SomeThings`, `SomeThings` is a collection of `Employee` entities. Thus, the `t` in your lambda expression will refer to an `Employee` object,...
541,174
<p>The following VBA code generates <code>&lt;?xml version="1.0"?&gt;</code> as output.</p> <pre><code>Dim XML As New DomDocument Dim pi As IXMLDOMProcessingInstruction '.... some code that sets the root element of the document Set pi = XML.createProcessingInstruction("xml", "version='1.0' encoding='UTF-8'") ...
[ { "answer_id": 541220, "author": "Rob Kennedy", "author_id": 33732, "author_profile": "https://Stackoverflow.com/users/33732", "pm_score": 3, "selected": true, "text": "<p>UTF-8 is the default encoding anyway. What you've specified is redundant, so the serializer likely omits it. The <co...
2009/02/12
[ "https://Stackoverflow.com/questions/541174", "https://Stackoverflow.com", "https://Stackoverflow.com/users/2605840/" ]
The following VBA code generates `<?xml version="1.0"?>` as output. ``` Dim XML As New DomDocument Dim pi As IXMLDOMProcessingInstruction '.... some code that sets the root element of the document Set pi = XML.createProcessingInstruction("xml", "version='1.0' encoding='UTF-8'") XML.insertBefore pi, XML.docu...
UTF-8 is the default encoding anyway. What you've specified is redundant, so the serializer likely omits it. The `version` field is not an optional field, though. If the file has an XML declaration at all, [the declaration must include the `version` field](http://www.w3.org/TR/REC-xml/#sec-prolog-dtd).
541,181
<p>This <a href="https://stackoverflow.com/questions/163162/can-you-call-directory-getfiles-with-multiple-filters">earlier SO question</a> talks about how to retrieve all files in a directory tree that match one of multiple extensions. </p> <p>eg. Retrieve all files within C:\ and all subdirectories, matching *.log, ...
[ { "answer_id": 541193, "author": "Konrad Rudolph", "author_id": 1968, "author_profile": "https://Stackoverflow.com/users/1968", "pm_score": 1, "selected": false, "text": "<p>You are right about the memory consumption. However, I think that's a fairly premature optimization. Loading an ar...
2009/02/12
[ "https://Stackoverflow.com/questions/541181", "https://Stackoverflow.com", "https://Stackoverflow.com/users/5023/" ]
This [earlier SO question](https://stackoverflow.com/questions/163162/can-you-call-directory-getfiles-with-multiple-filters) talks about how to retrieve all files in a directory tree that match one of multiple extensions. eg. Retrieve all files within C:\ and all subdirectories, matching \*.log, \*.txt, \*.dat. The ...
I shared your problem and I found the solution in Matthew Podwysocki's [excellent post](http://codebetter.com/blogs/matthew.podwysocki/archive/2008/10/16/functional-net-fighting-friction-in-the-bcl-with-directory-getfiles.aspx) at [codebetter.com](http://codebetter.com). He implemented a solution using native methods ...
541,189
<p>jQuery currently has <code>.next(filter)</code> and <code>.nextAll(filter)</code> but I need something that fits in the middle of these - effectively, a <code>.nextWhile(filter)</code> that repeatedly does next until the filter is no longer true, then stops (rather than continuing to the end).</p> <p>To demonstrate...
[ { "answer_id": 541351, "author": "Peter Boughton", "author_id": 9360, "author_profile": "https://Stackoverflow.com/users/9360", "pm_score": 1, "selected": false, "text": "<p><strong><em>UPDATE:</strong> Gave up on the recursion idea and decided to count and slice (see last example).</em>...
2009/02/12
[ "https://Stackoverflow.com/questions/541189", "https://Stackoverflow.com", "https://Stackoverflow.com/users/9360/" ]
jQuery currently has `.next(filter)` and `.nextAll(filter)` but I need something that fits in the middle of these - effectively, a `.nextWhile(filter)` that repeatedly does next until the filter is no longer true, then stops (rather than continuing to the end). To demonstrate this, the following is some simplified HTM...
In jQuery you can create `nextWhile()` equivalent using [`nextUntil()`](http://api.jquery.com/nextUntil/) method and [`:not`](http://api.jquery.com/not-selector/) selector. Simply put, *`while (condition is true) { do something }`* is same as saying *`until (condition is false) { do something }`*. Consider this trick...
541,194
<p>Does c# have its own version of the java "synchronized" keyword? </p> <p>I.e. in java it can be specified either to a function, an object or a block of code, like so:</p> <pre><code>public synchronized void doImportantStuff() { // dangerous code goes here. } </code></pre> <p>or</p> <pre><code>public void doIm...
[ { "answer_id": 541198, "author": "Konrad Rudolph", "author_id": 1968, "author_profile": "https://Stackoverflow.com/users/1968", "pm_score": 5, "selected": false, "text": "<blockquote>\n <p>Does c# have its own version of the java \"synchronized\" keyword? </p>\n</blockquote>\n\n<p>No. I...
2009/02/12
[ "https://Stackoverflow.com/questions/541194", "https://Stackoverflow.com", "https://Stackoverflow.com/users/24610/" ]
Does c# have its own version of the java "synchronized" keyword? I.e. in java it can be specified either to a function, an object or a block of code, like so: ``` public synchronized void doImportantStuff() { // dangerous code goes here. } ``` or ``` public void doImportantStuff() { // trivial stuff syn...
First - most classes will never need to be thread-safe. Use [YAGNI](http://en.wikipedia.org/wiki/You_aren't_gonna_need_it): only apply thread-safety when you know you actually are going to use it (and test it). For the method-level stuff, there is `[MethodImpl]`: ``` [MethodImpl(MethodImplOptions.Synchronized)] publi...
541,196
<p>how to make a class function with actionscript, I need to have a few static tool functions that are easily used from other classes like <strong>test = tools.rtrim(xx);</strong></p> <p>e.g. this does not compile:</p> <pre><code>package com.my.tools { static function rtrim(string:String):String { retur...
[ { "answer_id": 541297, "author": "Aaron Digulla", "author_id": 34088, "author_profile": "https://Stackoverflow.com/users/34088", "pm_score": 4, "selected": false, "text": "<p>We are all used to the fact that our desktop PC crashes once in a while (or at least an application on the deskto...
2009/02/12
[ "https://Stackoverflow.com/questions/541196", "https://Stackoverflow.com", "https://Stackoverflow.com/users/20979/" ]
how to make a class function with actionscript, I need to have a few static tool functions that are easily used from other classes like **test = tools.rtrim(xx);** e.g. this does not compile: ``` package com.my.tools { static function rtrim(string:String):String { return string.replace(/\s+$/,""); ...
**Are embedded developers more conservative than their desktop brethrens?** Yes, because they are more concerned with the consequences of making errors. It’s a big deal to patch an embedded device. Not so much for a desktop app. **Waterfallish development** is necessary in the embedded world because you are generall...
541,204
<p>I've:</p> <pre><code>function Obj1(param) { this.test1 = param || 1; } function Obj2(param, par) { this.test2 = param; } </code></pre> <p>now when I do:</p> <pre><code>Obj2.prototype = new Obj1(44); var obj = new Obj2(55); alert(obj.constructor) </code></pre> <p>I have:</p> <pre><code>function Obj1...
[ { "answer_id": 541268, "author": "Christoph", "author_id": 48015, "author_profile": "https://Stackoverflow.com/users/48015", "pm_score": 6, "selected": true, "text": "<p><code>constructor</code> is a regular property of the prototype object (with the <code>DontEnum</code> flag set so it ...
2009/02/12
[ "https://Stackoverflow.com/questions/541204", "https://Stackoverflow.com", "https://Stackoverflow.com/users/65120/" ]
I've: ``` function Obj1(param) { this.test1 = param || 1; } function Obj2(param, par) { this.test2 = param; } ``` now when I do: ``` Obj2.prototype = new Obj1(44); var obj = new Obj2(55); alert(obj.constructor) ``` I have: ``` function Obj1(param) { this.test1 = param || 1; } ``` but the const...
`constructor` is a regular property of the prototype object (with the `DontEnum` flag set so it doesn't show up in `for..in` loops). If you replace the prototype object, the `constructor` property will be replaced as well - see [this explanation](http://joost.zeekat.nl/constructors-considered-mildly-confusing.html) for...
541,225
<p>How can I set a DateTimePicker control to a specific date (yesterday's date) in C# .NET 2.0?</p>
[ { "answer_id": 541248, "author": "Rowland Shaw", "author_id": 50447, "author_profile": "https://Stackoverflow.com/users/50447", "pm_score": 7, "selected": true, "text": "<p>Just need to set the value property in a convenient place (such as <code>InitializeComponent()</code>):</p>\n\n<pre...
2009/02/12
[ "https://Stackoverflow.com/questions/541225", "https://Stackoverflow.com", "https://Stackoverflow.com/users/-1/" ]
How can I set a DateTimePicker control to a specific date (yesterday's date) in C# .NET 2.0?
Just need to set the value property in a convenient place (such as `InitializeComponent()`): ``` dateTimePicker1.Value = DateTime.Today.AddDays(-1); ```
541,235
<p>Like the title says, we’re looking for a way to catch all exceptions from a piece of C++ code, and wrap this in a dll. This way we can shield of the application that uses this dll, from any errors occurring in this dll.</p> <p>However, this does not seem possible with C++ under Windows. </p> <p>Example: </p> <pr...
[ { "answer_id": 541254, "author": "Community", "author_id": -1, "author_profile": "https://Stackoverflow.com/users/-1", "pm_score": 2, "selected": false, "text": "<p>Incrementing an iterator on a standard libary container will never throw a C++ exception. It may give you undefined behavio...
2009/02/12
[ "https://Stackoverflow.com/questions/541235", "https://Stackoverflow.com", "https://Stackoverflow.com/users/-1/" ]
Like the title says, we’re looking for a way to catch all exceptions from a piece of C++ code, and wrap this in a dll. This way we can shield of the application that uses this dll, from any errors occurring in this dll. However, this does not seem possible with C++ under Windows. Example: ``` void function() { ...
The only way to make a rock solid DLL wrapper is to load the buggy DLL in another process, so that if it crashes it doesn't take your primary process down with it. Catching all C++ exceptions seems reasonable, but catching all structured exceptions is another story. SEH might *seem* to get you most of the way there, ...
541,236
<p>I have a dropdown in a web page with 3830 elements in it. I know, excessive but whatever.</p> <p>In jquery I get the selected option value using the statement:</p> <p>$( "#institutionCombo :selected" ).val();</p> <p>There is a noticeable pause before the selection is found. Once I get that value I insert it into ...
[ { "answer_id": 541426, "author": "Julian", "author_id": 9811, "author_profile": "https://Stackoverflow.com/users/9811", "pm_score": 0, "selected": false, "text": "<p>You could do this:</p>\n\n<p>var ix = $( \"#institutionCombo\" ).attr( \"selectedIndex\" );</p>\n\n<p>var value = $( \"#in...
2009/02/12
[ "https://Stackoverflow.com/questions/541236", "https://Stackoverflow.com", "https://Stackoverflow.com/users/20651/" ]
I have a dropdown in a web page with 3830 elements in it. I know, excessive but whatever. In jquery I get the selected option value using the statement: $( "#institutionCombo :selected" ).val(); There is a noticeable pause before the selection is found. Once I get that value I insert it into a textbox on the page, s...
There is no need to call the :selected when getting the val of a select box. The default behavior is to get the selectedIndex ``` $( "#institutionCombo").val(); ``` As noted in the comment, If you need to access the text of that option you can use ``` $( "#institutionCombo option[value=" + $( "#institutionCombo")....
541,243
<p>'Order by' returns this result below</p> <pre> 05 05/1-1 05/1-2 05/1-3 05/1-4 05/1-5 05/1-6 05/1-7 05/1 05/2-1 05/2-2 05/2-3 05/2-4 05/2 05/3 05/4 </pre> <p></p> <p>and this order below is OK</p> <pre> 05 05/1 05/1-1 05/1-2 05/1-3 05/1-4 05/1-5 05/1-6 05/1-7 05/2 05/2-1 05/2-2 05/2-3 05/2-4 05/3 05/4 </pre> <p>...
[ { "answer_id": 541266, "author": "tehvan", "author_id": 61848, "author_profile": "https://Stackoverflow.com/users/61848", "pm_score": 1, "selected": false, "text": "<p>If possible, try to split up the data, so that any numeric information is in its own field.\nString data and numeric dat...
2009/02/12
[ "https://Stackoverflow.com/questions/541243", "https://Stackoverflow.com", "https://Stackoverflow.com/users/65541/" ]
'Order by' returns this result below ``` 05 05/1-1 05/1-2 05/1-3 05/1-4 05/1-5 05/1-6 05/1-7 05/1 05/2-1 05/2-2 05/2-3 05/2-4 05/2 05/3 05/4 ``` and this order below is OK ``` 05 05/1 05/1-1 05/1-2 05/1-3 05/1-4 05/1-5 05/1-6 05/1-7 05/2 05/2-1 05/2-2 05/2-3 05/2-4 05/3 05/4 ``` Is there a way to do this?
If possible, try to split up the data, so that any numeric information is in its own field. String data and numeric data together in a field will always result in string type of data, so that 'A2' > 'A11'.
541,247
<p>I'm working on a simple copy tool to copy files off digital cameras. I've written the file copy code, I've got everything hooked up nicely.</p> <p>The issue I have seems to be with the FolderBrowserDialog. In Vista (I haven't checked XP yet), I can browse to the directories on the camera. However the FolderBrowserD...
[ { "answer_id": 547647, "author": "Pedro", "author_id": 13188, "author_profile": "https://Stackoverflow.com/users/13188", "pm_score": 0, "selected": false, "text": "<p>Is there a way to map the camera path to a drive letter? (I'm thinking something like \"subst\" or \"net use\" from a com...
2009/02/12
[ "https://Stackoverflow.com/questions/541247", "https://Stackoverflow.com", "https://Stackoverflow.com/users/11453/" ]
I'm working on a simple copy tool to copy files off digital cameras. I've written the file copy code, I've got everything hooked up nicely. The issue I have seems to be with the FolderBrowserDialog. In Vista (I haven't checked XP yet), I can browse to the directories on the camera. However the FolderBrowserDialog will...
My guess would be that the location doesn't have a file system representation (path) such as c:...\my camera. You should be able to get the PIDL of the folder, (it should be one the the flags for the function), and implement the copy using the COM shell interfaces. [SHBrowseForFolder](http://msdn.microsoft.com/en-us/...
541,255
<p>I am testing a function pointer called ErrorLoggingMethod in a C# DLL to prevent exceptions due to a null value, as below, but it seems that at runtime, the function is actually being executed when I really mean to test its delegate for null. I am inadvertently getting a null exception as a result--just what I am t...
[ { "answer_id": 541276, "author": "Konrad Rudolph", "author_id": 1968, "author_profile": "https://Stackoverflow.com/users/1968", "pm_score": 2, "selected": false, "text": "<p>Are you sure you don't get the exception as a result of <code>udt</code> being <code>null</code>? You're not calli...
2009/02/12
[ "https://Stackoverflow.com/questions/541255", "https://Stackoverflow.com", "https://Stackoverflow.com/users/65544/" ]
I am testing a function pointer called ErrorLoggingMethod in a C# DLL to prevent exceptions due to a null value, as below, but it seems that at runtime, the function is actually being executed when I really mean to test its delegate for null. I am inadvertently getting a null exception as a result--just what I am tryin...
I might not be understanding what you're asking but...If you're trying to know whether the delegate has any methods in its invocation list you can just check the length of the list... ``` if (ErrorLoggingMethod.GetInvocationList().Length(0) == 0){ //Add your default handler to the delegate } ``` Then run your Ad...
541,263
<p>How to free up memory and destroy Array, is it ok to do just like this</p> <pre><code> myarr = null myarr = new Array </code></pre> <p>is all the old content of myarr now freed from memory?</p>
[ { "answer_id": 541285, "author": "AnthonyWJones", "author_id": 17516, "author_profile": "https://Stackoverflow.com/users/17516", "pm_score": 2, "selected": true, "text": "<p>Assuming you haven't got another reference to the array in another variable somewhere the arrays memory will be re...
2009/02/12
[ "https://Stackoverflow.com/questions/541263", "https://Stackoverflow.com", "https://Stackoverflow.com/users/20979/" ]
How to free up memory and destroy Array, is it ok to do just like this ``` myarr = null myarr = new Array ``` is all the old content of myarr now freed from memory?
Assuming you haven't got another reference to the array in another variable somewhere the arrays memory will be recovered when the GC gets to it.
541,286
<p>I want to get all the values associated with a key in Map. For e.g,</p> <pre><code>Map tempMap = new HashMap(); tempMap.put("1","X"); tempMap.put("2","Y"); tempMap.put("3","Z"); tempMap.put("1","ABC"); tempMap.put("2","RR"); tempMap.put("1","RT"); </code></pre> <p>How to retrieve all the values associated with key...
[ { "answer_id": 541302, "author": "IAdapter", "author_id": 30453, "author_profile": "https://Stackoverflow.com/users/30453", "pm_score": 2, "selected": false, "text": "<p>can't</p>\n\n<p>try using <a href=\"http://code.google.com/p/google-collections/\" rel=\"nofollow noreferrer\">google ...
2009/02/12
[ "https://Stackoverflow.com/questions/541286", "https://Stackoverflow.com", "https://Stackoverflow.com/users/-1/" ]
I want to get all the values associated with a key in Map. For e.g, ``` Map tempMap = new HashMap(); tempMap.put("1","X"); tempMap.put("2","Y"); tempMap.put("3","Z"); tempMap.put("1","ABC"); tempMap.put("2","RR"); tempMap.put("1","RT"); ``` How to retrieve all the values associated with key 1 ?
What you can do is this: ``` Map<String, List<String>> tempMap = new HashMap<String, List<String>>(); tempMap.put("1", new LinkedList<String>()); tempMap.get("1").add("X"); tempMap.get("1").add("Y"); tempMap.get("1").add("Z"); for(String value : tempMap.get("1")) { //do something } ``` This compartmentalizes valu...
541,289
<p>I saw the "new type" <code>BOOL</code> (<code>YES</code>, <code>NO</code>).</p> <p>I read that this type is almost like a char.</p> <p>For testing I did :</p> <pre><code>NSLog(@"Size of BOOL %d", sizeof(BOOL)); NSLog(@"Size of bool %d", sizeof(bool)); </code></pre> <p>Good to see that both logs display "1" (some...
[ { "answer_id": 541352, "author": "Jeff", "author_id": 54742, "author_profile": "https://Stackoverflow.com/users/54742", "pm_score": 3, "selected": false, "text": "<p>Yup, BOOL is a typedef for a signed char according to objc.h.</p>\n\n<p>I don't know about bool, though. That's a C++ thi...
2009/02/12
[ "https://Stackoverflow.com/questions/541289", "https://Stackoverflow.com", "https://Stackoverflow.com/users/65500/" ]
I saw the "new type" `BOOL` (`YES`, `NO`). I read that this type is almost like a char. For testing I did : ``` NSLog(@"Size of BOOL %d", sizeof(BOOL)); NSLog(@"Size of bool %d", sizeof(bool)); ``` Good to see that both logs display "1" (sometimes in C++ bool is an int and its sizeof is 4) So I was just wondering...
From the definition in `objc.h`: ``` #if (TARGET_OS_IPHONE && __LP64__) || TARGET_OS_WATCH typedef bool BOOL; #else typedef signed char BOOL; // BOOL is explicitly signed so @encode(BOOL) == "c" rather than "C" // even if -funsigned-char is used. #endif #define YES ((BOOL)1) #define NO ((BOOL)0) ``` So, yes, y...
541,293
<p>I am running a Web Service in C# .NET 3.5. I want to log various calls. However since many users are hitting the same functions at once it is difficult to tell which log call belongs to which.</p> <p>In a C++ life we used a thread Id. What is the equivalent in C#?</p> <p>I have tried</p> <pre><code>System.Diag...
[ { "answer_id": 541310, "author": "Rytmis", "author_id": 266, "author_profile": "https://Stackoverflow.com/users/266", "pm_score": 2, "selected": false, "text": "<p>Mayhaps Thread.CurrentThread.ManagedThreadId </p>\n" }, { "answer_id": 541318, "author": "Vojislav Stojkovic", ...
2009/02/12
[ "https://Stackoverflow.com/questions/541293", "https://Stackoverflow.com", "https://Stackoverflow.com/users/2469/" ]
I am running a Web Service in C# .NET 3.5. I want to log various calls. However since many users are hitting the same functions at once it is difficult to tell which log call belongs to which. In a C++ life we used a thread Id. What is the equivalent in C#? I have tried ``` System.Diagnostics.Process proc = System.D...
If you use MS Ent Lib and their logger you can use the Tracer class to get some nice logging: Example ``` public Output MyServiceMethod(Input input, string transactionId) { using(new Tracer("MyServiceMethod: " + transactionId)) { ... stuff ... return output; } } ``` You can even nest Tra...
541,295
<p>Canvas doesn't seem to play well together nicely with the other elements when you try to build it into a layout and have e.g. controls on the side and the canvas is the drawing area.</p> <p>For instance, why can I put a border around every element except a canvas? In the following code, border wraps canvas but the ...
[ { "answer_id": 541372, "author": "user7116", "author_id": 7116, "author_profile": "https://Stackoverflow.com/users/7116", "pm_score": 2, "selected": true, "text": "<p>From what I can tell in XamlPad, the problem appears to be that your Canvas does not have an explicit height/width, and t...
2009/02/12
[ "https://Stackoverflow.com/questions/541295", "https://Stackoverflow.com", "https://Stackoverflow.com/users/4639/" ]
Canvas doesn't seem to play well together nicely with the other elements when you try to build it into a layout and have e.g. controls on the side and the canvas is the drawing area. For instance, why can I put a border around every element except a canvas? In the following code, border wraps canvas but the canvas onl...
From what I can tell in XamlPad, the problem appears to be that your Canvas does not have an explicit height/width, and that its HorizontalAlignment defaults to being in the middle of the Border. Without an explicit height and width the Border appears to collapse to 0 height and stretches on the width. My assumption is...
541,314
<p>Currently we are looking at moving our development environment from CodeWright (which has long since been abandonned by Borland) and moving to Eclipse. We are using Eclipse for Perl, PHP and some Windows C++ development with much success.</p> <p>The issue comes up however with our embedded environment which uses ...
[ { "answer_id": 542745, "author": "apekarske", "author_id": 65323, "author_profile": "https://Stackoverflow.com/users/65323", "pm_score": 0, "selected": false, "text": "<p>You could make a header file that is included with #defines for the things Eclipse doesn't know about. Then as part ...
2009/02/12
[ "https://Stackoverflow.com/questions/541314", "https://Stackoverflow.com", "https://Stackoverflow.com/users/65547/" ]
Currently we are looking at moving our development environment from CodeWright (which has long since been abandonned by Borland) and moving to Eclipse. We are using Eclipse for Perl, PHP and some Windows C++ development with much success. The issue comes up however with our embedded environment which uses - in the mak...
We tried the #defines in the header directive but because of the size of the project as well as the sheer number of files, that turned out to be a not too practical approach. Tooling around Eclipse we found a solution that works for us and it is detailed below: 1. Right click on the project in question. 2. Select Pro...
541,322
<p>Say I have a view in my database, and I want to send a file to someone to create that view's output as a table in their database.</p> <p>mysqldump of course only exports the 'create view...' statement (well, okay, it includes the create table, but no data).</p> <p>What I have done is simply duplicate the view as a...
[ { "answer_id": 541355, "author": "Paul Tomblin", "author_id": 3333, "author_profile": "https://Stackoverflow.com/users/3333", "pm_score": 2, "selected": false, "text": "<p>One option would be to do a query into a CSV file and import that. To select into a CSV file:</p>\n\n<p>From <a hre...
2009/02/12
[ "https://Stackoverflow.com/questions/541322", "https://Stackoverflow.com", "https://Stackoverflow.com/users/65548/" ]
Say I have a view in my database, and I want to send a file to someone to create that view's output as a table in their database. mysqldump of course only exports the 'create view...' statement (well, okay, it includes the create table, but no data). What I have done is simply duplicate the view as a real table and d...
Same problem here my problem is that I want to export view definition (84 fields and millions of records) as a "create table" statement, because view can variate along time and I want an automatic process. So that's what I did: 1. Create table from view but with no records `mysql -uxxxx -pxxxxxx my_db -e "create tabl...
541,331
<p>That is the solution to make a negative from a image in C# Windows Forms without any dlls and in a effective, fast way?</p>
[ { "answer_id": 541340, "author": "Sandeep Datta", "author_id": 39648, "author_profile": "https://Stackoverflow.com/users/39648", "pm_score": 0, "selected": false, "text": "<p>Go through all the pixels one by one (Bitmap.GetPixel() or something) and subtract the RGB values from 0xff to cr...
2009/02/12
[ "https://Stackoverflow.com/questions/541331", "https://Stackoverflow.com", "https://Stackoverflow.com/users/38940/" ]
That is the solution to make a negative from a image in C# Windows Forms without any dlls and in a effective, fast way?
The best way to do this is directly accessing the pixels with bitmap data. Just to add some timing details: Performing Negate on an 8 Megapixel Image (on a 2.4 Ghz Core 2 Duo): * SetPixel (~22 seconds) - 220 Times slower * Color Matrix, Matajon's method below (~750 milliseconds) - 7 times slower * Directly accesing ...
541,335
<p>I've got some jsp files that are supposed to output xhtml. They seem to have the correct doctype etc but Eclipse is not parsing the xhtml attributes. For instance for the root element:</p> <pre><code>&lt;html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en"&gt; </code></pre> <p>I get the warning: "Unde...
[ { "answer_id": 541353, "author": "Ian Devlin", "author_id": 17896, "author_profile": "https://Stackoverflow.com/users/17896", "pm_score": 3, "selected": true, "text": "<p>That seems odd, I use the same in Eclipse but with PHP and it works fine. </p>\n\n<p>What is the DOCTYPE that you use...
2009/02/12
[ "https://Stackoverflow.com/questions/541335", "https://Stackoverflow.com", "https://Stackoverflow.com/users/10098/" ]
I've got some jsp files that are supposed to output xhtml. They seem to have the correct doctype etc but Eclipse is not parsing the xhtml attributes. For instance for the root element: ``` <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en"> ``` I get the warning: "Undefined attribute name (xmlns)." W...
That seems odd, I use the same in Eclipse but with PHP and it works fine. What is the DOCTYPE that you use? I've used `<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">`
541,345
<p>I am having an issue on Sorting a ListBox with a dropdown. The dropdown will have 2 options:</p> <ol> <li><p>Sort By #</p></li> <li><p>Sort By Type</p></li> </ol> <p>The ListBox contains a list of items which are initially ordered in ascending order by #. It has the following format:</p> <ol> <li>1: Red</li> <l...
[ { "answer_id": 541503, "author": "themue", "author_id": 25814, "author_profile": "https://Stackoverflow.com/users/25814", "pm_score": 1, "selected": false, "text": "<p>The problems will stay almost the same inf future, but the underlying hardware for the realization is changing. To use t...
2009/02/12
[ "https://Stackoverflow.com/questions/541345", "https://Stackoverflow.com", "https://Stackoverflow.com/users/33690/" ]
I am having an issue on Sorting a ListBox with a dropdown. The dropdown will have 2 options: 1. Sort By # 2. Sort By Type The ListBox contains a list of items which are initially ordered in ascending order by #. It has the following format: 1. 1: Red 2. 2: Green 3. 3: Blue 4. 4: Red 5. 5: Red If the user choses Sor...
Before we had operating systems people building applications would sit down and discuss things like: * how will we store data on disks * what file system structure will we use * what hardware will our application work with * etc, etc Operating systems emerged from collections of 'developer libraries'. The beauty of ...
541,362
<p>I'm trying to make a quick jquery plugin (as a learning exercise) for making a simple pager from a list of items (LIs in this case) and have run into a problem when passing the current selector (this) to a sub-function. The code is below.</p> <p>The problem is when creating the dynamic nav (the plugin requires jqu...
[ { "answer_id": 541387, "author": "quark", "author_id": 46680, "author_profile": "https://Stackoverflow.com/users/46680", "pm_score": 3, "selected": true, "text": "<pre><code>var selector = $(this);\n$(\".pageNav a\").live(\"click\", function() {\n // do something\n selector.hide();\n})...
2009/02/12
[ "https://Stackoverflow.com/questions/541362", "https://Stackoverflow.com", "https://Stackoverflow.com/users/65557/" ]
I'm trying to make a quick jquery plugin (as a learning exercise) for making a simple pager from a list of items (LIs in this case) and have run into a problem when passing the current selector (this) to a sub-function. The code is below. The problem is when creating the dynamic nav (the plugin requires jquery 1.3) an...
``` var selector = $(this); $(".pageNav a").live("click", function() { // do something selector.hide(); }); ```
541,370
<p>this is the structure of my source xml:</p> <pre><code>&lt;root&gt; &lt;DataSet Value="A"&gt; &lt;Data Value1="1" Value2="anythingA1" /&gt; &lt;Data Value1="2" Value2="anythingA2" /&gt; &lt;Data Value1="3" Value2="anythingA3" /&gt; &lt;Data Value1="4" Value2="anythingA4" /&gt; &lt;Data Value1="5" Value2="anythingA5...
[ { "answer_id": 541374, "author": "phihag", "author_id": 35070, "author_profile": "https://Stackoverflow.com/users/35070", "pm_score": 6, "selected": false, "text": "<p>Just remove the slash after <code>Data</code> and prepend the root:</p>\n\n<pre><code>&lt;xsl:variable name=\"myVarA\" s...
2009/02/12
[ "https://Stackoverflow.com/questions/541370", "https://Stackoverflow.com", "https://Stackoverflow.com/users/-1/" ]
this is the structure of my source xml: ``` <root> <DataSet Value="A"> <Data Value1="1" Value2="anythingA1" /> <Data Value1="2" Value2="anythingA2" /> <Data Value1="3" Value2="anythingA3" /> <Data Value1="4" Value2="anythingA4" /> <Data Value1="5" Value2="anythingA5" /> </DataSet> </root> ``` from which I like to cr...
Just remove the slash after `Data` and prepend the root: ``` <xsl:variable name="myVarA" select="/root/DataSet/Data[@Value1='2']/@Value2"/> ```
541,390
<p>Is there a function to extract the extension from a filename?</p>
[ { "answer_id": 541394, "author": "nosklo", "author_id": 17160, "author_profile": "https://Stackoverflow.com/users/17160", "pm_score": 12, "selected": true, "text": "<p>Use <a href=\"https://docs.python.org/3/library/os.path.html#os.path.splitext\" rel=\"noreferrer\"><code>os.path.splitex...
2009/02/12
[ "https://Stackoverflow.com/questions/541390", "https://Stackoverflow.com", "https://Stackoverflow.com/users/85185/" ]
Is there a function to extract the extension from a filename?
Use [`os.path.splitext`](https://docs.python.org/3/library/os.path.html#os.path.splitext): ``` >>> import os >>> filename, file_extension = os.path.splitext('/path/to/somefile.ext') >>> filename '/path/to/somefile' >>> file_extension '.ext' ``` Unlike most manual string-splitting attempts, `os.path.splitext` will co...
541,398
<p>Context: ASP.NET 3.5 / C#</p> <p>Hi,</p> <p>I created a user control</p> <pre><code>public partial class MyControl : UserControl { // EDIT: example first used "UniqueId" as property name, which was wrong. public Guid MyId { get; set; } // ... } </code></pre> <p>and this example usage</p> <pre><code>...
[ { "answer_id": 541428, "author": "Nick Berardi", "author_id": 17, "author_profile": "https://Stackoverflow.com/users/17", "pm_score": 0, "selected": false, "text": "<p>You have a couple problems here, but first I will answer your questions about the workarounds. </p>\n\n<ol>\n<li>No you...
2009/02/12
[ "https://Stackoverflow.com/questions/541398", "https://Stackoverflow.com", "https://Stackoverflow.com/users/65545/" ]
Context: ASP.NET 3.5 / C# Hi, I created a user control ``` public partial class MyControl : UserControl { // EDIT: example first used "UniqueId" as property name, which was wrong. public Guid MyId { get; set; } // ... } ``` and this example usage ``` <uc1:MyControl ID="myControl" MyId="443CB...
[Custom Design-time Control Features in Visual Studio .NET](http://msdn.microsoft.com/en-us/magazine/cc164048.aspx#S6)
541,407
<p>One of the people who took the time to comment on <a href="https://stackoverflow.com/questions/535277/the-clojure-or-lisp-equivalent-of-a-compound-boolean-test">my other question</a> about Clojure/LISP syntax pointed out that I had not written my sample code in the standard LISP way. So he was kind enough to rewrit...
[ { "answer_id": 541429, "author": "starblue", "author_id": 49246, "author_profile": "https://Stackoverflow.com/users/49246", "pm_score": 0, "selected": false, "text": "<p>When you have 10 parentheses to close, it becomes really clunky.</p>\n\n<p>When I used to program Lisp I left a space ...
2009/02/12
[ "https://Stackoverflow.com/questions/541407", "https://Stackoverflow.com", "https://Stackoverflow.com/users/2820/" ]
One of the people who took the time to comment on [my other question](https://stackoverflow.com/questions/535277/the-clojure-or-lisp-equivalent-of-a-compound-boolean-test) about Clojure/LISP syntax pointed out that I had not written my sample code in the standard LISP way. So he was kind enough to rewrite the code snip...
The closing parentheses on extra lines don't really help with seeing the structure of the code, because you can get the same information from the level of indentation. However, the second form takes up almost twice as many lines, forcing you to scroll more often when reading code. And if you need to inspect the nested...
541,409
<p>I've begun playing a bit with implementing an IQueryable&lt;T&gt; datatype to query using LINQ. For example I've made a couple of functions like this (It is just a temporary detail that the extension method is not for the specific IQueryable implementation):</p> <pre><code>public static IQueryable&lt;T&gt; Pow&lt;T...
[ { "answer_id": 541480, "author": "Marc Gravell", "author_id": 23354, "author_profile": "https://Stackoverflow.com/users/23354", "pm_score": 1, "selected": false, "text": "<p>You are looking for the <code>.Select()</code> method</p>\n" }, { "answer_id": 541496, "author": "Crai...
2009/02/12
[ "https://Stackoverflow.com/questions/541409", "https://Stackoverflow.com", "https://Stackoverflow.com/users/4055/" ]
I've begun playing a bit with implementing an IQueryable<T> datatype to query using LINQ. For example I've made a couple of functions like this (It is just a temporary detail that the extension method is not for the specific IQueryable implementation): ``` public static IQueryable<T> Pow<T>(this IQueryable<T> values, ...
It seems to me that you are inventing [Select](http://msdn.microsoft.com/en-us/library/bb534638.aspx). I don't see the difference between your Map and what Select already does. It returns an IQueryable<U> based on an expression and an initial IQueryable<T>. For something like Reduce/Fold, see the [Queryable.Aggregate]...
541,415
<p>I am looking to do the following with a single database query if possible.</p> <pre><code>public class Location { public string URL {get;set;} public IList&lt;Page&gt; Pages {get;set;} } Page firstPage = Session.Linq&lt;Location&gt;() .Where(location =&gt; location.URL == "some-location-url...
[ { "answer_id": 541437, "author": "Tomas Aschan", "author_id": 38055, "author_profile": "https://Stackoverflow.com/users/38055", "pm_score": 2, "selected": false, "text": "<p>You are looking for a <a href=\"http://aspalliance.com/1545_Understanding_Single_SignOn_in_ASPNET_20.all\" rel=\"n...
2009/02/12
[ "https://Stackoverflow.com/questions/541415", "https://Stackoverflow.com", "https://Stackoverflow.com/users/65193/" ]
I am looking to do the following with a single database query if possible. ``` public class Location { public string URL {get;set;} public IList<Page> Pages {get;set;} } Page firstPage = Session.Linq<Location>() .Where(location => location.URL == "some-location-url") .Select(lo...
You are looking for a [Single Site Login](http://aspalliance.com/1545_Understanding_Single_SignOn_in_ASPNET_20.all) solution. If the article I linked to doesn't help you, there's plenty more on [google](http://www.google.com) when you know what to [search](http://www.google.com/search?ie=UTF-8&oe=UTF-8&sourceid=navclie...
541,420
<p>I have a rectangle in my XAML and want to change its <code>Canvas.Left</code> property in code behind:</p> <pre class="lang-xml prettyprint-override"><code>&lt;UserControl x:Class="Second90.Page" xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns:x="http://schemas.microsoft.com/winfx/2...
[ { "answer_id": 541443, "author": "JaredPar", "author_id": 23283, "author_profile": "https://Stackoverflow.com/users/23283", "pm_score": 6, "selected": false, "text": "<p>Try this</p>\n\n<pre><code>theObject.SetValue(Canvas.LeftProperty, 50d);\n</code></pre>\n\n<p>There is a group of meth...
2009/02/12
[ "https://Stackoverflow.com/questions/541420", "https://Stackoverflow.com", "https://Stackoverflow.com/users/4639/" ]
I have a rectangle in my XAML and want to change its `Canvas.Left` property in code behind: ```xml <UserControl x:Class="Second90.Page" xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" Width="400" Height="300" KeyDown="txt_KeyDown"> ...
``` Canvas.SetLeft(theObject, 50) ```
541,421
<p>When you write something in BASIC, you are required to use line numbers. Like:</p> <pre><code>10 PRINT "HOME" 20 PRINT "SWEET" 30 GOTO 10 </code></pre> <p>But I wonder: who came up with the idea to use line numbers at all? It is such a nuisance, and left quite an "echo" in the developing (pun intended) world!</p>
[ { "answer_id": 541439, "author": "balexandre", "author_id": 28004, "author_profile": "https://Stackoverflow.com/users/28004", "pm_score": 1, "selected": false, "text": "<p>in Basic, if you didn't have a line number, how can you preform a </p>\n\n<pre><code>GOTO 10 \n</code></pre>\n\n<p>t...
2009/02/12
[ "https://Stackoverflow.com/questions/541421", "https://Stackoverflow.com", "https://Stackoverflow.com/users/62662/" ]
When you write something in BASIC, you are required to use line numbers. Like: ``` 10 PRINT "HOME" 20 PRINT "SWEET" 30 GOTO 10 ``` But I wonder: who came up with the idea to use line numbers at all? It is such a nuisance, and left quite an "echo" in the developing (pun intended) world!
The idea back then was that you could easily add code everywhere in your program by using the appropriate line number. That's why everybody uses line numbers 10, 20, 30.. so there is room left: ``` 10 PRINT "HOME" 20 PRINT "SWEET" 30 GOTO 10 25 PRINT "HOME" ``` On the first interfaces BASIC was available for, there ...
541,423
<p>I am working with ASP.NET 3.5, VB.NET, and I am trying to validate some inputs through a regular expression.</p> <p>My expression is:</p> <pre>^[a-zA-Z'_''-''/'' ''\''@''&''.'',''ç''Ç''ö''Ö''I''ı''i''İ''ğ''Ğ''ş''Ş''ü''Ü'\s\d]{1,50}$</pre> <p>And it works for all the special characters I included except for the "<...
[ { "answer_id": 541431, "author": "Joel Coehoorn", "author_id": 3043, "author_profile": "https://Stackoverflow.com/users/3043", "pm_score": 2, "selected": false, "text": "<p>The - character has special meaning in that context. Escape it with a backslash or list it as the last character i...
2009/02/12
[ "https://Stackoverflow.com/questions/541423", "https://Stackoverflow.com", "https://Stackoverflow.com/users/57845/" ]
I am working with ASP.NET 3.5, VB.NET, and I am trying to validate some inputs through a regular expression. My expression is: ``` ^[a-zA-Z'_''-''/'' ''\''@''&''.'',''ç''Ç''ö''Ö''I''ı''i''İ''ğ''Ğ''ş''Ş''ü''Ü'\s\d]{1,50}$ ``` And it works for all the special characters I included except for the "**-**". It just doesn...
Why all the single quotes? They are unnecessary. ``` ^[-a-zA-Z_/\\@&.,çÇöÖIiiIgGsSüÜ\s\d]{1,50}$ ^ ^^ ``` Move the "-" to the start or the end of the character class to have it recognized. Also, the backslash needs to be escaped properly, or you won't be able to match backslashes either. See the "^" marks a...
541,424
<p>I love <a href="http://www.prototypejs.org/api" rel="nofollow noreferrer">Prototype</a> but it doesn't come with any widgets. In particular, it provides nothing for window/dialog creation.</p> <p>I've tried the <a href="http://prototype-window.xilinus.com/" rel="nofollow noreferrer">Prototype Window</a> add-on libr...
[ { "answer_id": 541457, "author": "meouw", "author_id": 12161, "author_profile": "https://Stackoverflow.com/users/12161", "pm_score": 0, "selected": false, "text": "<p><a href=\"http://script.aculo.us/\" rel=\"nofollow noreferrer\">Scriptaculous</a> is a UI/Widget/effects library built on...
2009/02/12
[ "https://Stackoverflow.com/questions/541424", "https://Stackoverflow.com", "https://Stackoverflow.com/users/65555/" ]
I love [Prototype](http://www.prototypejs.org/api) but it doesn't come with any widgets. In particular, it provides nothing for window/dialog creation. I've tried the [Prototype Window](http://prototype-window.xilinus.com/) add-on library but found it unreliable and it hasn't been maintained for a long time. Anyone h...
For a really simple dialog, checkout this code: <http://snippets.dzone.com/posts/show/3411> Very minimal and simple - just what I wanted. The code went through a few modifications. Here's the final version that worked for me: ``` /* * Adapted from http://snippets.dzone.com/posts/show/3411 */ var Dialog = {}; Dia...
541,427
<p>What Flash player version is required by Flex 3 app ?</p> <p>Requirement seems to be HTML WRAPPER/ACTIONSCRIPT compiler setting inside FLEX development environment; what can I choose there to allow maximum compatibility with old flash players? Will v8 player work?</p>
[ { "answer_id": 541457, "author": "meouw", "author_id": 12161, "author_profile": "https://Stackoverflow.com/users/12161", "pm_score": 0, "selected": false, "text": "<p><a href=\"http://script.aculo.us/\" rel=\"nofollow noreferrer\">Scriptaculous</a> is a UI/Widget/effects library built on...
2009/02/12
[ "https://Stackoverflow.com/questions/541427", "https://Stackoverflow.com", "https://Stackoverflow.com/users/20979/" ]
What Flash player version is required by Flex 3 app ? Requirement seems to be HTML WRAPPER/ACTIONSCRIPT compiler setting inside FLEX development environment; what can I choose there to allow maximum compatibility with old flash players? Will v8 player work?
For a really simple dialog, checkout this code: <http://snippets.dzone.com/posts/show/3411> Very minimal and simple - just what I wanted. The code went through a few modifications. Here's the final version that worked for me: ``` /* * Adapted from http://snippets.dzone.com/posts/show/3411 */ var Dialog = {}; Dia...
541,430
<p>How should I read any header in PHP?</p> <p>For example the custom header: <code>X-Requested-With</code>.</p>
[ { "answer_id": 541450, "author": "Quassnoi", "author_id": 55159, "author_profile": "https://Stackoverflow.com/users/55159", "pm_score": 9, "selected": false, "text": "<pre><code>$_SERVER['HTTP_X_REQUESTED_WITH']\n</code></pre>\n\n<p><a href=\"http://www.faqs.org/rfcs/rfc3875.html\" rel=\...
2009/02/12
[ "https://Stackoverflow.com/questions/541430", "https://Stackoverflow.com", "https://Stackoverflow.com/users/48625/" ]
How should I read any header in PHP? For example the custom header: `X-Requested-With`.
**IF**: you only need a single header, instead of *all* headers, the quickest method is: ``` <?php // Replace XXXXXX_XXXX with the name of the header you need in UPPERCASE (and with '-' replaced by '_') $headerStringValue = $_SERVER['HTTP_XXXXXX_XXXX']; ``` **ELSE IF**: you run PHP as an Apache module or, as of PHP ...
541,466
<p>Is there a way to add a parameter to an IN clause using System.Data.OracleClient.</p> <p>For example:</p> <pre><code>string query = "SELECT * FROM TableName WHERE UserName IN (:Pram)"; OracleCommand command = new OracleCommand(query, conn); command.Parameters.Add(":Pram", OracleType.VarChar).Value = "'Ben', 'Sam'"...
[ { "answer_id": 541514, "author": "Yasin B", "author_id": 65055, "author_profile": "https://Stackoverflow.com/users/65055", "pm_score": 1, "selected": false, "text": "<p>That way your query will be:</p>\n\n<pre>SELECT * FROM TableName WHERE UserName IN ('''Ben'', ''Sam''');</pre>\n\n<p>Th...
2009/02/12
[ "https://Stackoverflow.com/questions/541466", "https://Stackoverflow.com", "https://Stackoverflow.com/users/19067/" ]
Is there a way to add a parameter to an IN clause using System.Data.OracleClient. For example: ``` string query = "SELECT * FROM TableName WHERE UserName IN (:Pram)"; OracleCommand command = new OracleCommand(query, conn); command.Parameters.Add(":Pram", OracleType.VarChar).Value = "'Ben', 'Sam'"; ```
You can do it more easily with `ODP.NET`: 1. Create a `TABLE` type in your database: ``` CREATE TYPE t_varchar2 AS TABLE OF VARCHAR2(4000); ``` 2. Create a collection parameter: ``` OracleParameter param = new OracleParameter(); param.OracleDbType = OracleDbType.Varchar2; param.CollectionType = OracleCollectionType...
541,467
<p>I'm having problems using the Html.DropDownList helper on a MVC RC1 form. </p> <p>In the controller class, I create a SelectList like this</p> <pre><code>SelectList selectList = new SelectList(db.SiteAreas, "AreaId", "AreaName"); ViewData["AreaId"] = selectList; </code></pre> <p>or like this</p> <pre><code>IEnum...
[ { "answer_id": 541631, "author": "Dave The Ninja", "author_id": 65193, "author_profile": "https://Stackoverflow.com/users/65193", "pm_score": 1, "selected": false, "text": "<p>Have you re-upgraded to the RC1 refresh?</p>\n\n<p><a href=\"http://www.haacked.com/archive/2009/01/30/aspnetmvc...
2009/02/12
[ "https://Stackoverflow.com/questions/541467", "https://Stackoverflow.com", "https://Stackoverflow.com/users/2756/" ]
I'm having problems using the Html.DropDownList helper on a MVC RC1 form. In the controller class, I create a SelectList like this ``` SelectList selectList = new SelectList(db.SiteAreas, "AreaId", "AreaName"); ViewData["AreaId"] = selectList; ``` or like this ``` IEnumerable<SelectListItem> areaList = from a...
This is not a bug in MVC and is by design (AFAIK) You need to re-set your viewdata and return the model back to the view. The view data only exists for the current request + 1 (i.e the post back).
541,468
<p>If I create a custom control with WPF, how can I provide styles for the control that match the currently applied theme (Aero, Luna, Classic, etc.)?</p> <p>For example I'd like to apply the following when using Aero:</p> <pre><code>&lt;Style&gt; &lt;Setter Property="Background" Value="White"/&gt; &lt;/Style&gt;...
[ { "answer_id": 543735, "author": "Muad'Dib", "author_id": 49910, "author_profile": "https://Stackoverflow.com/users/49910", "pm_score": 0, "selected": false, "text": "<p>You can use different themes in WPF by loading/unloading resource dictionaries. These dictionaries should contain the...
2009/02/12
[ "https://Stackoverflow.com/questions/541468", "https://Stackoverflow.com", "https://Stackoverflow.com/users/62891/" ]
If I create a custom control with WPF, how can I provide styles for the control that match the currently applied theme (Aero, Luna, Classic, etc.)? For example I'd like to apply the following when using Aero: ``` <Style> <Setter Property="Background" Value="White"/> </Style> ``` But then apply a different style...
Some links that might be prove helpful: <http://arbel.net/blog/archive/2006/11/03/Forcing-WPF-to-use-a-specific-Windows-theme.aspx> <http://www.browsoft.com/tutorials/DefaultTheme.html> <http://blogs.msdn.com/wpfsdk/archive/2007/07/31/using-themes-with-custom-controls.aspx> Basically you create resource dictionarie...
541,472
<p>I've only dealt with one-to-one relationships in php so far, but I'm stuck on a problem which involves a one-to-many relationship. I've been sitting on this for a few days with no luck, so I'm desperate for someone to step in and show me a solution before I lose my mind.</p> <p>In my database have a series of urls,...
[ { "answer_id": 541513, "author": "Ólafur Waage", "author_id": 22459, "author_profile": "https://Stackoverflow.com/users/22459", "pm_score": 0, "selected": false, "text": "<p>You should be using a connection table.</p>\n\n<p>1st you have a table of links</p>\n\n<pre><code>id = 1 url = som...
2009/02/12
[ "https://Stackoverflow.com/questions/541472", "https://Stackoverflow.com", "https://Stackoverflow.com/users/46502/" ]
I've only dealt with one-to-one relationships in php so far, but I'm stuck on a problem which involves a one-to-many relationship. I've been sitting on this for a few days with no luck, so I'm desperate for someone to step in and show me a solution before I lose my mind. In my database have a series of urls, which are...
There is also the "GROUP\_CONCAT" function in mysql. That should do exactly what you want to achieve. Something like : ``` SELECT url, GROUP_CONCAT(category) AS categories FROM yourtable GROUP BY url ```
541,481
<p>I have some code which does the following:</p> <pre><code>const string KEY_CHK = "Microsoft.IW.PartCheck"; SPWeb curWeb = SPContext.Current.Web; if (!curWeb.Properties.ContainsKey(KEY_CHK)) { curWeb.Properties.Add(KEY_CHK, "true"); curWeb.Properties.Update(); } </code></pre> <p>This runs as a webpart in a m...
[ { "answer_id": 541697, "author": "Jason", "author_id": 10639, "author_profile": "https://Stackoverflow.com/users/10639", "pm_score": 0, "selected": false, "text": "<p>nope, you cannot set web properties via the UI. maybe there's something on CodePlex </p>\n" }, { "answer_id": 54...
2009/02/12
[ "https://Stackoverflow.com/questions/541481", "https://Stackoverflow.com", "https://Stackoverflow.com/users/13911/" ]
I have some code which does the following: ``` const string KEY_CHK = "Microsoft.IW.PartCheck"; SPWeb curWeb = SPContext.Current.Web; if (!curWeb.Properties.ContainsKey(KEY_CHK)) { curWeb.Properties.Add(KEY_CHK, "true"); curWeb.Properties.Update(); } ``` This runs as a webpart in a master page in Sharepoint 2...
Try using SharePoint Manager 2007 from <http://www.codeplex.com/spm>. .b
541,487
<p>From what time I've spent with threads in <code>Java</code>, I've found these two ways to write threads:</p> <p>With <strong>implements <code>Runnable</code>:</strong></p> <pre><code>public class MyRunnable implements Runnable { public void run() { //Code } } //Started with a &quot;new Thread(new MyR...
[ { "answer_id": 541500, "author": "Powerlord", "author_id": 15880, "author_profile": "https://Stackoverflow.com/users/15880", "pm_score": 5, "selected": false, "text": "<p>I'm not an expert, but I can think of one reason to implement Runnable instead of extend Thread: Java only supports s...
2009/02/12
[ "https://Stackoverflow.com/questions/541487", "https://Stackoverflow.com", "https://Stackoverflow.com/users/65374/" ]
From what time I've spent with threads in `Java`, I've found these two ways to write threads: With **implements `Runnable`:** ``` public class MyRunnable implements Runnable { public void run() { //Code } } //Started with a "new Thread(new MyRunnable()).start()" call ``` Or, with **extends `Thread`:...
Yes: implements `Runnable` is the preferred way to do it, IMO. You're not really specialising the thread's behaviour. You're just giving it something to run. That means [composition](http://en.wikipedia.org/wiki/Object_composition) is the *philosophically* "purer" way to go. In *practical* terms, it means you can impl...
541,494
<p>sorry for asking this, but i'm runnin' out of ideas</p> <p>i have this table:</p> <pre><code>[id] [pid] [vid] 1 4 6844 1 5 6743 2 3 855 2 6 888 ... </code></pre> <p>how to i query this eg.table to get the following result:</p> <pre><code>[id] [pid]...
[ { "answer_id": 541528, "author": "SQLMenace", "author_id": 740, "author_profile": "https://Stackoverflow.com/users/740", "pm_score": 2, "selected": false, "text": "<p>one way</p>\n\n<pre><code>select t1.* from\n(select id,max(pid) as Maxpid\nfrom yourtable\ngroup by id) t2\njoin yourtabl...
2009/02/12
[ "https://Stackoverflow.com/questions/541494", "https://Stackoverflow.com", "https://Stackoverflow.com/users/-1/" ]
sorry for asking this, but i'm runnin' out of ideas i have this table: ``` [id] [pid] [vid] 1 4 6844 1 5 6743 2 3 855 2 6 888 ... ``` how to i query this eg.table to get the following result: ``` [id] [pid] [vid] 1 5 6743 2 6 ...
I would use Common Table Expressions (CTE). This offers lots of possibilities like so: ``` WITH Result (RowNumber, [id], [pid], [vid]) AS ( SELECT Row_Number() OVER (PARTITION BY [id] ORDER BY [vid] DESC) ,[id] ,[pid] ,[vid] FROM MyTable ) SELEC...
541,510
<p>I am reading through a directory with some pictures and such using a pretty simple implementation of readdir() like the following:</p> <pre><code>if ($handle = opendir($path)) { while (false !== ($szFilename = readdir($handle))) { if ($szFilename[0] !== '.') { if (is_file($path.$szFilename)) { ...
[ { "answer_id": 541525, "author": "SilentGhost", "author_id": 12855, "author_profile": "https://Stackoverflow.com/users/12855", "pm_score": 2, "selected": false, "text": "<p>i suppose docs are quite clear here.</p>\n\n<blockquote>\n <p>order in which they are stored in filesystem</p>\n</...
2009/02/12
[ "https://Stackoverflow.com/questions/541510", "https://Stackoverflow.com", "https://Stackoverflow.com/users/2106/" ]
I am reading through a directory with some pictures and such using a pretty simple implementation of readdir() like the following: ``` if ($handle = opendir($path)) { while (false !== ($szFilename = readdir($handle))) { if ($szFilename[0] !== '.') { if (is_file($path.$szFilename)) { // ...
Alphabetical order :: I think you misread the snippet you quoted... > > Returns the filename of the next file from the directory. The filenames are returned in the order in which they are stored by the filesystem. > > > The fact that 'ls' would display the files in (usually) alphabetical order does not mean that'...
541,542
<blockquote> <p>disconnect invalidates 1 active statement handle (either destroy statement handles or call finish on them before disconnecting)</p> </blockquote> <p>The following code which grabs data from MySQL gets executed successfully, but will cause Apache to generate the above message in its error log:</...
[ { "answer_id": 541558, "author": "Paul Tomblin", "author_id": 3333, "author_profile": "https://Stackoverflow.com/users/3333", "pm_score": 5, "selected": true, "text": "<p>You should call <code>$statement-&gt;finish();</code> before <code>$db_handle-&gt;disconnnect();</code>. </p>\n\n<p>N...
2009/02/12
[ "https://Stackoverflow.com/questions/541542", "https://Stackoverflow.com", "https://Stackoverflow.com/users/22556/" ]
> > disconnect invalidates 1 active > statement handle (either destroy > statement handles or call finish on > them before disconnecting) > > > The following code which grabs data from MySQL gets executed successfully, but will cause Apache to generate the above message in its error log: ``` my $driver = "my...
You should call `$statement->finish();` before `$db_handle->disconnnect();`. Normally you don't need to call `finish`, unless you're not getting all the rows. If you get all the results in a loop using `fetchrow_array`, you don't call finish at the end unless you aborted the loop. I'm not sure why the MySQL driver ...
541,545
<p>When you have a table with a Geometry type field (or Geography), you can call the <code>Reduce()</code> function to have the shapes reduced in number of vertices. Works very nicely. However, when sevral of the polygons are adjacent (they share parts of their borders), the reduced polygons do not necessarily do so. <...
[ { "answer_id": 557179, "author": "BradC", "author_id": 21398, "author_profile": "https://Stackoverflow.com/users/21398", "pm_score": 2, "selected": false, "text": "<p>Wow, that's a pretty cool set of features. </p>\n\n<p>Taking a look at some of the other methods available, here are a fe...
2009/02/12
[ "https://Stackoverflow.com/questions/541545", "https://Stackoverflow.com", "https://Stackoverflow.com/users/64963/" ]
When you have a table with a Geometry type field (or Geography), you can call the `Reduce()` function to have the shapes reduced in number of vertices. Works very nicely. However, when sevral of the polygons are adjacent (they share parts of their borders), the reduced polygons do not necessarily do so. Example -----...
I'm not sure how you'd get the "shared" LineStrings from your shapes. Secondly, once you reduce a "subset" of the shape since your endpoints may move from the original and you will not be able to make them match up after reduction. The nutshell of what I would do is basically use boolean operations to play with the re...
541,546
<p>I am using a pre-build task in Visual Studio 2008 that invokes msbuild:</p> <pre><code>C:\WINDOWS\Microsoft.NET\Framework\v3.5\MSBuild.exe $(MSBuildProjectDirectory)\version.targets /p:Configuration=$(ConfigurationName) </code></pre> <p>Inside version.targets, I am updating the AssemblyInfo.cs file to replace vers...
[ { "answer_id": 646153, "author": "laktak", "author_id": 52817, "author_profile": "https://Stackoverflow.com/users/52817", "pm_score": 6, "selected": true, "text": "<p>I don't think you are doing anything wrong - it's a bug.</p>\n\n<p>I have reported it <a href=\"https://connect.microsoft...
2009/02/12
[ "https://Stackoverflow.com/questions/541546", "https://Stackoverflow.com", "https://Stackoverflow.com/users/2258/" ]
I am using a pre-build task in Visual Studio 2008 that invokes msbuild: ``` C:\WINDOWS\Microsoft.NET\Framework\v3.5\MSBuild.exe $(MSBuildProjectDirectory)\version.targets /p:Configuration=$(ConfigurationName) ``` Inside version.targets, I am updating the AssemblyInfo.cs file to replace version information: ``` <...
I don't think you are doing anything wrong - it's a bug. I have reported it [here](https://connect.microsoft.com/VisualStudio/feedback/ViewFeedback.aspx?FeedbackID=423670) - check if you can reproduce it and add a validation, maybe we can get it fixed by MS. EDIT: I tried the suggestion by "Si" to update the file in ...
541,559
<p>I have an MsAccess 2003 application which is a dashboard to launching other MsAccess apps.</p> <p>I employ the API ShellExecute to launch/open the MsAccess app as below:</p> <pre><code>lngReturn = ShellExecute(Application.hWndAccessApp, _ "Open", _ AccessMDBN...
[ { "answer_id": 541621, "author": "bruceatk", "author_id": 791, "author_profile": "https://Stackoverflow.com/users/791", "pm_score": 2, "selected": false, "text": "<p>To me it seems unlikely (but nothing is impossible) that it's the 10MB file size. Are the files in the same place? The E...
2009/02/12
[ "https://Stackoverflow.com/questions/541559", "https://Stackoverflow.com", "https://Stackoverflow.com/users/13370/" ]
I have an MsAccess 2003 application which is a dashboard to launching other MsAccess apps. I employ the API ShellExecute to launch/open the MsAccess app as below: ``` lngReturn = ShellExecute(Application.hWndAccessApp, _ "Open", _ AccessMDBName, _ ...
To me it seems unlikely (but nothing is impossible) that it's the 10MB file size. Are the files in the same place? The Errorcode=5 means access denied. As part of starting Access an ldb file has to be created or updated. Is it possible that your files are in a different location and the person does not have write acces...
541,561
<p>Hello i been trying to get a tokenizer to work using the boost library tokenizer class. I found this tutorial on the boost documentation:</p> <p><a href="http://www.boost.org/doc/libs/1_36_0/libs/tokenizer/escaped_list_separator.htm" rel="nofollow noreferrer">http://www.boost.org/doc/libs/1 &#95;36 &#95;0/libs/toke...
[ { "answer_id": 541821, "author": "pk.", "author_id": 10615, "author_profile": "https://Stackoverflow.com/users/10615", "pm_score": 3, "selected": false, "text": "<p>It seems like you're declaring your tokenizer type incorrectly.</p>\n\n<pre><code>typedef boost::tokenizer&lt; boost::escap...
2009/02/12
[ "https://Stackoverflow.com/questions/541561", "https://Stackoverflow.com", "https://Stackoverflow.com/users/2021317/" ]
Hello i been trying to get a tokenizer to work using the boost library tokenizer class. I found this tutorial on the boost documentation: [http://www.boost.org/doc/libs/1 \_36 \_0/libs/tokenizer/escaped \_list \_separator.htm](http://www.boost.org/doc/libs/1_36_0/libs/tokenizer/escaped_list_separator.htm) problem is ...
try this: ``` #include <iostream> #include <boost/tokenizer.hpp> #include <string> int main() { using namespace std; using namespace boost; string s = "exec script1 \"script argument number one\""; string separator1("");//dont let quoted arguments escape themselves string separator2(" ");//split o...
541,577
<p>C#: I want to pass messages like a file path to my forms application like a console application, how would I do that?</p> <p>I was told I needed to find my main method to add string[] args, but I wouldn't know which one that would be in Windows Forms. Which would my main method be in C# windows forms application?</...
[ { "answer_id": 541592, "author": "JaredPar", "author_id": 23283, "author_profile": "https://Stackoverflow.com/users/23283", "pm_score": 2, "selected": false, "text": "<p>If you want to get access to the command line parameters, use Environment.CommandLine</p>\n\n<pre><code>string args = ...
2009/02/12
[ "https://Stackoverflow.com/questions/541577", "https://Stackoverflow.com", "https://Stackoverflow.com/users/-1/" ]
C#: I want to pass messages like a file path to my forms application like a console application, how would I do that? I was told I needed to find my main method to add string[] args, but I wouldn't know which one that would be in Windows Forms. Which would my main method be in C# windows forms application?
Ok, string[] args = Environment.GetCommandLineArgs() is a better option. But I will keep the following answer as an alternative to it. Look for a file called Program.cs containing the following code fragment... ``` static class Program { /// <summary> /// The main entry point for the application. /// </su...
541,579
<p>How can I handle the <kbd>Return</kbd> key (<code>VK_RETURN</code>) in a <code>CEdit</code> control? The <code>CEdit</code> control is parented to a <code>CDialog</code>.</p>
[ { "answer_id": 541625, "author": "SAMills", "author_id": 56546, "author_profile": "https://Stackoverflow.com/users/56546", "pm_score": 2, "selected": false, "text": "<p>Make certain the Edit Control style ES_WANTRETURN is set in the dialog resource for the control</p>\n" }, { "an...
2009/02/12
[ "https://Stackoverflow.com/questions/541579", "https://Stackoverflow.com", "https://Stackoverflow.com/users/36830/" ]
How can I handle the `Return` key (`VK_RETURN`) in a `CEdit` control? The `CEdit` control is parented to a `CDialog`.
You could also filter for the key in your dialog's PreTranslateMessage. If you get `WM_KEYDOWN` for `VK_RETURN`, call `GetFocus`. If focus is on your edit control, call your handling for return pressed in the edit control. Note the order of clauses in the if relies on short-circuiting to be efficient. ``` BOOL CMyDia...
541,590
<p>The following regular expression works if there is no space character, but if the input has a space character, it doesn't work (it seems like a link but JavaScript doesn't work).</p> <p>How can I change it? </p> <p>The regular expression should work for both <code>World</code> and <code>The World</code>.</p> <pre...
[ { "answer_id": 541617, "author": "Buggabill", "author_id": 2106, "author_profile": "https://Stackoverflow.com/users/2106", "pm_score": 2, "selected": false, "text": "<p>Actually, there is a space 'character'. It is a '\\s' (minus the quotes).</p>\n" }, { "answer_id": 541618, ...
2009/02/12
[ "https://Stackoverflow.com/questions/541590", "https://Stackoverflow.com", "https://Stackoverflow.com/users/-1/" ]
The following regular expression works if there is no space character, but if the input has a space character, it doesn't work (it seems like a link but JavaScript doesn't work). How can I change it? The regular expression should work for both `World` and `The World`. ``` Dim makebkz As String Dim pattern A...
I think this line should be changed: ``` str = regex.Replace(str, "(bkz: <a href=javascript:" & myAnchor.HRef & "><font color=""#CC0000"">$1</font></a> )") ``` If I read your code correctly you are including the $1 in the HRef (that's what the Page.GetPostBackEventReference(myAnchor, "$1") is doing), and then replac...
541,620
<p>Hi I was wondering if anyone knew of some good websites detailing prevention for SQL injection for .NET web applications. Any resources would be greatly appricated, thank you.</p>
[ { "answer_id": 541638, "author": "thinkbeforecoding", "author_id": 47001, "author_profile": "https://Stackoverflow.com/users/47001", "pm_score": 1, "selected": false, "text": "<p>If you use the SqlCommand.Parameters collection to pass parameters and never inject user text into you Sql qu...
2009/02/12
[ "https://Stackoverflow.com/questions/541620", "https://Stackoverflow.com", "https://Stackoverflow.com/users/-1/" ]
Hi I was wondering if anyone knew of some good websites detailing prevention for SQL injection for .NET web applications. Any resources would be greatly appricated, thank you.
I think that, if you google a bit on 'preventing sql injection in .NET', you'll find lots of good resources. :) Anyway, one very important thing, is to not use string-concatenation in order to build your queries. Instead, use parametrized queries. ADO.NET allows to do this, in a very easy way: ``` string sql = "SELEC...
541,635
<p>Ex : I want something like abc.hyd.mycompany.com. My requirement is to parse this name and initialize appropriate service.</p> <pre><code>using System.Net; Dns.GetHostName() // doesn't return fully qualified name it just gives "abc" </code></pre>
[ { "answer_id": 541747, "author": "Powerlord", "author_id": 15880, "author_profile": "https://Stackoverflow.com/users/15880", "pm_score": 7, "selected": true, "text": "<p>You may be able to get the whole DNS string like this:</p>\n\n<pre><code>System.Net.Dns.GetHostEntry(\"\").HostName\n<...
2009/02/12
[ "https://Stackoverflow.com/questions/541635", "https://Stackoverflow.com", "https://Stackoverflow.com/users/21246/" ]
Ex : I want something like abc.hyd.mycompany.com. My requirement is to parse this name and initialize appropriate service. ``` using System.Net; Dns.GetHostName() // doesn't return fully qualified name it just gives "abc" ```
You may be able to get the whole DNS string like this: ``` System.Net.Dns.GetHostEntry("").HostName ``` We don't have full fledged DNS names where I work, but it does give me a three level faux domain name instead of just the hostname. Edit 2011/03/17: Incorporated changes suggested by mark below.
541,649
<p>Assume that I have Person and Address Classes and they have different tables in DB.</p> <p>One Person can have one Address Class in it. This is the important part for me. One Person can <strong>have only one</strong> Address as it s child element and i want to keep them in different tables in DB.</p> <p>Normally i...
[ { "answer_id": 541810, "author": "CalvinR", "author_id": 55990, "author_profile": "https://Stackoverflow.com/users/55990", "pm_score": 0, "selected": false, "text": "<p>Are you sure it's a one to one relationship? I would assume it's a many-to-one relationship as usually more then one pe...
2009/02/12
[ "https://Stackoverflow.com/questions/541649", "https://Stackoverflow.com", "https://Stackoverflow.com/users/51734/" ]
Assume that I have Person and Address Classes and they have different tables in DB. One Person can have one Address Class in it. This is the important part for me. One Person can **have only one** Address as it s child element and i want to keep them in different tables in DB. Normally i know that i need to hold them...
You can't map Address using a component because it has its own table. You could use it if you had all fields in just one table. From the Hibernate reference: > > The component element maps properties of a child object to columns of the table of a parent class. > > > You should use a one-to-one relationship to ma...
541,650
<p>I try to write any code about days:</p> <pre><code>function xyz("13.02.2009") { return value= 6; } function xyz("12.02.2009") { return value= 5; } function xyz("14.02.2009") { return value= 7; } </code></pre> <p>But how?</p> <p>This method is good but I need C# times specific codes (like timespan......
[ { "answer_id": 541665, "author": "teedyay", "author_id": 15825, "author_profile": "https://Stackoverflow.com/users/15825", "pm_score": -1, "selected": false, "text": "<pre><code>return (int)(myDateTime.DayOfWeek);\n</code></pre>\n" }, { "answer_id": 541667, "author": "Anton G...
2009/02/12
[ "https://Stackoverflow.com/questions/541650", "https://Stackoverflow.com", "https://Stackoverflow.com/users/52420/" ]
I try to write any code about days: ``` function xyz("13.02.2009") { return value= 6; } function xyz("12.02.2009") { return value= 5; } function xyz("14.02.2009") { return value= 7; } ``` But how? This method is good but I need C# times specific codes (like timespan...) ``` DayOfWeek day = DateTime.P...
Note that DateTime.DayOfWeek depends on your regional settings.
541,655
<p>I have a number of rows from a database which I want to insert into another database. Since there's quite a few rows I want to use the INSERT .. SELECT ... construct in mysql. The statement I try to run is as follows:</p> <pre><code>set @rank := 1; set @currpoints := 0; set @currgroupcount := 0; SELECT id, @rank...
[ { "answer_id": 541707, "author": "chaos", "author_id": 47529, "author_profile": "https://Stackoverflow.com/users/47529", "pm_score": 1, "selected": false, "text": "<p>You could hide the increment using something like:</p>\n\n<pre><code>SELECT IF(@currpoints := points, id, id)\n</code></p...
2009/02/12
[ "https://Stackoverflow.com/questions/541655", "https://Stackoverflow.com", "https://Stackoverflow.com/users/65584/" ]
I have a number of rows from a database which I want to insert into another database. Since there's quite a few rows I want to use the INSERT .. SELECT ... construct in mysql. The statement I try to run is as follows: ``` set @rank := 1; set @currpoints := 0; set @currgroupcount := 0; SELECT id, @rank := if( @currp...
``` INSERT INTO new_characters (id, name) SELECT id, name FROM ( SELECT id, @rank := if( @currpoints = points, @rank , @rank + @currgroupcount ) AS rank, @currgroupcount := if( @currpoints = points, @currgroupcount +1, 1 ), @currpoints := points FROM characters ORDER BY points DESC , name LIMIT 0 , 30 ) ...
541,657
<p>I have a query that takes too long and frequently times out. It's a proximity based zip code search table-value function. Is there anyway to index based on the query, so it doesn't have to recalculate all of these values every time? The postal code and zip code list combined is over a million rows.</p> <p>Here is t...
[ { "answer_id": 541683, "author": "SQLMenace", "author_id": 740, "author_profile": "https://Stackoverflow.com/users/740", "pm_score": 2, "selected": false, "text": "<p>It takes me milliseconds, maybe your approach is wrong take a look here: <a href=\"http://blogs.lessthandot.com/index.php...
2009/02/12
[ "https://Stackoverflow.com/questions/541657", "https://Stackoverflow.com", "https://Stackoverflow.com/users/26/" ]
I have a query that takes too long and frequently times out. It's a proximity based zip code search table-value function. Is there anyway to index based on the query, so it doesn't have to recalculate all of these values every time? The postal code and zip code list combined is over a million rows. Here is the table f...
I would recommend an multi-column index on Longitude and Latitude. It's good that you are using a bounding box, which would ordinarily speed up your query. With the index I mention, you should see huge improvements. On a side note, you have your latitude/longitudes stored in a Decimal(16,12). 12 digits of precision i...
541,669
<p>Currently I got this type of query generated by programmation (c#)</p> <pre><code>INSERT INTO TableName (Field1, Field2, Field3) SELECT Field1, Field2, Field3 FROM TableName2 </code></pre> <p>The problem is that the SELECT can have a result of many records (like a million), so it's take many times and the result i...
[ { "answer_id": 541682, "author": "Marc Gravell", "author_id": 23354, "author_profile": "https://Stackoverflow.com/users/23354", "pm_score": 3, "selected": false, "text": "<p>Well, if it is a full copy, I wonder if you shouldn't look into bulk load tools?</p>\n\n<ul>\n<li>BULK INSERT (TSQ...
2009/02/12
[ "https://Stackoverflow.com/questions/541669", "https://Stackoverflow.com", "https://Stackoverflow.com/users/60002/" ]
Currently I got this type of query generated by programmation (c#) ``` INSERT INTO TableName (Field1, Field2, Field3) SELECT Field1, Field2, Field3 FROM TableName2 ``` The problem is that the SELECT can have a result of many records (like a million), so it's take many times and the result is an connection timeout. ...
I've found out that, if you have a lot of INSERT statements that are executed in sequence, you can improve performance by adding a 'GO' statement after each xxxx number of insert statements: ``` ... INSERT INTO Table ( ... ) VALUES ( ... ) INSERT INTO Table ( ... ) VALUES ( ... ) INSERT INTO Table ( ... ) VALUES ( ......
541,670
<p>I have a macro taking several parameters. Some of these are optional and if a parameter is left empty it will replaced with default.</p> <p>Now the question is how to make this as easy as possible for ordinary web designer. Is there any other possibity apart from my examples to handle this case?</p> <p>Example 1: ...
[ { "answer_id": 593492, "author": "Will Glass", "author_id": 32978, "author_profile": "https://Stackoverflow.com/users/32978", "pm_score": 4, "selected": true, "text": "<p>As of Velocity 1.6, optional or named parameters are not supported. There was a recent patch submitted with this fea...
2009/02/12
[ "https://Stackoverflow.com/questions/541670", "https://Stackoverflow.com", "https://Stackoverflow.com/users/28841/" ]
I have a macro taking several parameters. Some of these are optional and if a parameter is left empty it will replaced with default. Now the question is how to make this as easy as possible for ordinary web designer. Is there any other possibity apart from my examples to handle this case? Example 1: The obvious pro...
As of Velocity 1.6, optional or named parameters are not supported. There was a recent patch submitted with this feature so we might see it available in a future release. In the meantime, consider passing in a list or a map of values. For example you can pass in a map of params as follows (requires Velocity 1.5 or gre...
541,693
<p>I'm a newbie to using SSIS for data imports - I have a couple of files that I want to import into my database schema, but I'm going to need to run this once every 3 months; the file names change based on the quarter e.g. <code>SKU1QTR</code> will become <code>SKU2QTR</code>. </p> <p>How can I handle a situation li...
[ { "answer_id": 541717, "author": "SQLMenace", "author_id": 740, "author_profile": "https://Stackoverflow.com/users/740", "pm_score": 2, "selected": true, "text": "<p>Create a script task and do something like this, where FlatFileCSV would be the name of your connection</p>\n\n<pre><code>...
2009/02/12
[ "https://Stackoverflow.com/questions/541693", "https://Stackoverflow.com", "https://Stackoverflow.com/users/40667/" ]
I'm a newbie to using SSIS for data imports - I have a couple of files that I want to import into my database schema, but I'm going to need to run this once every 3 months; the file names change based on the quarter e.g. `SKU1QTR` will become `SKU2QTR`. How can I handle a situation like this with SSIS? Is there a way...
Create a script task and do something like this, where FlatFileCSV would be the name of your connection ``` Dts.Connections("FlatFileCSV").ConnectionString = "E:\SomeFile" + theDate.ToString("yyyyMMdd") + ".csv" ```
541,694
<p>Most programmers agree that garbage collection is a great thing, and in most applications is well worth the overhead. However, my personal observation is that memory management for most objects is trivial, and maybe 10%-20% of them account for the need for kludges such as reference counting and really complicated m...
[ { "answer_id": 541752, "author": "mafu", "author_id": 39590, "author_profile": "https://Stackoverflow.com/users/39590", "pm_score": 1, "selected": false, "text": "<p>A quick note on the \"obviously no longer needed\": It's not THAT easy ;)</p>\n\n<pre><code>[...]\nFoo() {\n someGlobal...
2009/02/12
[ "https://Stackoverflow.com/questions/541694", "https://Stackoverflow.com", "https://Stackoverflow.com/users/23903/" ]
Most programmers agree that garbage collection is a great thing, and in most applications is well worth the overhead. However, my personal observation is that memory management for most objects is trivial, and maybe 10%-20% of them account for the need for kludges such as reference counting and really complicated memor...
Because this case is too rare. Almost no method is isolated. They all accept objects from outside or create objects and pass them out. A method which doesn't access any fields, doesn't has parameters and doesn't return something can't do anything. Instead, the GCs concentrate on the most common case (the 90%) and tr...
541,705
<p>In the C programming language, it is my understanding that variables can only be defined at the beginning of a code block, and the variable will have the scope of the block it was declared in. With that in mind, I was wondering whether it is considered bad practice to artificially create a new scope as in this exam...
[ { "answer_id": 541710, "author": "Lars Mæhlum", "author_id": 960, "author_profile": "https://Stackoverflow.com/users/960", "pm_score": 3, "selected": false, "text": "<p>You probably want to create a new function for that scope.<br>\nIf it truly needs to have it's own scope, it's probably...
2009/02/12
[ "https://Stackoverflow.com/questions/541705", "https://Stackoverflow.com", "https://Stackoverflow.com/users/35767/" ]
In the C programming language, it is my understanding that variables can only be defined at the beginning of a code block, and the variable will have the scope of the block it was declared in. With that in mind, I was wondering whether it is considered bad practice to artificially create a new scope as in this example:...
You don't even need an if statement. You can create blocks with {} That should probably be a separate function however. Example here: ``` #include <stdio.h> int main(int argc, char **argv) { int i = 0; { int i = 10; printf("%d\n", i); } printf("%d\n", i); } ```
541,712
<p>How do you Login to FTP using C#? </p>
[ { "answer_id": 541729, "author": "bendewey", "author_id": 37881, "author_profile": "https://Stackoverflow.com/users/37881", "pm_score": 3, "selected": false, "text": "<p>Here is a very nice FTP Client for C#</p>\n\n<p><a href=\"http://www.codeproject.com/KB/IP/ftplibrary.aspx\" rel=\"nof...
2009/02/12
[ "https://Stackoverflow.com/questions/541712", "https://Stackoverflow.com", "https://Stackoverflow.com/users/65578/" ]
How do you Login to FTP using C#?
Here is a very nice FTP Client for C# <http://www.codeproject.com/KB/IP/ftplibrary.aspx> Snippett from Link ------------------ ``` //Get the basic FtpWebRequest object with the //common settings and security private FtpWebRequest GetRequest(string URI) { //create request FtpWebRequest result = (FtpWebRequest...
541,713
<p>Cursor disappears when </p> <pre><code>TextField.selectable = false; </code></pre> <p>How can I make cursor to be visible but textfield not selectable(with mouse) or CTRL+A.</p>
[ { "answer_id": 541785, "author": "Kristoffer Sall-Storgaard", "author_id": 3287, "author_profile": "https://Stackoverflow.com/users/3287", "pm_score": 0, "selected": false, "text": "<p>I believe flash/as3 sees the text cursor as a zero width selection, I dont see how it should be possibl...
2009/02/12
[ "https://Stackoverflow.com/questions/541713", "https://Stackoverflow.com", "https://Stackoverflow.com/users/20979/" ]
Cursor disappears when ``` TextField.selectable = false; ``` How can I make cursor to be visible but textfield not selectable(with mouse) or CTRL+A.
I've seen a similar problem in the past, but I don't remember how to duplicate it. It no longer appears in the project I first saw it in, so the two things which I know have happened since then are below. Of course, there could be some other variable, but the project is working now... I suspect that the field is still...
541,716
<p>I am tearing my hair out over this one. What tools do people use to debug formatting issues with css? I have some relatively simple formatting for navigation using css which looks like this:</p> <pre><code>/* sub navigation */ .sidenav { float: right; width: 218px; } .sidenav h1 { background: #BCB39F ...
[ { "answer_id": 541728, "author": "BigJump", "author_id": 8542, "author_profile": "https://Stackoverflow.com/users/8542", "pm_score": 4, "selected": false, "text": "<p>To answer the actual question title : I use <a href=\"http://getfirebug.com/\" rel=\"nofollow noreferrer\">FireBug</a>!</...
2009/02/12
[ "https://Stackoverflow.com/questions/541716", "https://Stackoverflow.com", "https://Stackoverflow.com/users/52494/" ]
I am tearing my hair out over this one. What tools do people use to debug formatting issues with css? I have some relatively simple formatting for navigation using css which looks like this: ``` /* sub navigation */ .sidenav { float: right; width: 218px; } .sidenav h1 { background: #BCB39F url(img/sidenavh...
[`firebug`](http://www.getfirebug.com/). There is also a pure javascript version that works in IE, called [`firebug lite`](http://getfirebug.com/lite.html). It allows you to turn off or change any `CSS` you want on the fly.
541,732
<p>I'm writing an asp.net mvc app and I've get a list of service calls that I display in a table. When the user clicks the table header I want to tell my controller to sort the list by that column. </p> <pre><code>public ActionResult Index(int? page, string sortBy, string sortDirection) { int pageIndex =...
[ { "answer_id": 541823, "author": "Dave Swersky", "author_id": 34796, "author_profile": "https://Stackoverflow.com/users/34796", "pm_score": 0, "selected": false, "text": "<p>When sorting a generic list, you can provide the way to compare for sorting with an overload of <code>List&lt;T&gt...
2009/02/12
[ "https://Stackoverflow.com/questions/541732", "https://Stackoverflow.com", "https://Stackoverflow.com/users/9938/" ]
I'm writing an asp.net mvc app and I've get a list of service calls that I display in a table. When the user clicks the table header I want to tell my controller to sort the list by that column. ``` public ActionResult Index(int? page, string sortBy, string sortDirection) { int pageIndex = page == null ? ...
Don't forget about the handy-dandy DataBinder: ``` var serviceCalls = sc.Service.GetOpenServiceCalls("").OrderBy(call => DataBinder.Eval(call, sortBy)); return serviceCalls.ToPagedList(pageIndex, 2); ``` DataBinder.Eval from Msdn docs > > Uses reflection to parse and evaluate > a data-binding expression again an ...
541,749
<p>If class <code>B</code> and class <code>C</code> extend class <code>A</code> and I have an object of type <code>B</code> or <code>C</code>, how can I determine of which type it is an instance?</p>
[ { "answer_id": 541763, "author": "Bill the Lizard", "author_id": 1288, "author_profile": "https://Stackoverflow.com/users/1288", "pm_score": 9, "selected": false, "text": "<p>Use <a href=\"https://docs.oracle.com/en/java/javase/17/docs/api/java.base/java/lang/Object.html#getClass()\" rel...
2009/02/12
[ "https://Stackoverflow.com/questions/541749", "https://Stackoverflow.com", "https://Stackoverflow.com/users/20498/" ]
If class `B` and class `C` extend class `A` and I have an object of type `B` or `C`, how can I determine of which type it is an instance?
``` if (obj instanceof C) { //your code } ```
541,758
<p>I am dynamically creating Word documents using the Velocity template engine. The documents are created in XML (using the Microsoft Office 2003 WordprocessML XML standard). </p> <p>I am embedding an image (encoded in Base64 format) inside the WordML in the traditional way:</p> <pre><code>&lt;w:pict&gt; &lt;v:...
[ { "answer_id": 3397799, "author": "Maxim Grachev", "author_id": 409790, "author_profile": "https://Stackoverflow.com/users/409790", "pm_score": 0, "selected": false, "text": "<p>You need to set width and height in \"style\" attribute of \"v:shape\" element to 0px. For example:</p>\n\n<pr...
2009/02/12
[ "https://Stackoverflow.com/questions/541758", "https://Stackoverflow.com", "https://Stackoverflow.com/users/-1/" ]
I am dynamically creating Word documents using the Velocity template engine. The documents are created in XML (using the Microsoft Office 2003 WordprocessML XML standard). I am embedding an image (encoded in Base64 format) inside the WordML in the traditional way: ``` <w:pict> <v:shapeType> ... </v:shapeType> ...
If you are using xslt templates you can write some C# script in your template like that(it's for metafiles(.wmf) but you can rewrite it for Bitmap class to use with .jpg format): ``` <msxsl:script language="C#" implements-prefix="user"> <msxsl:assembly name="System.Drawing" /> <msxsl:using namespace="System.D...
541,784
<p>Is there a wait statement in c-component? for example, wait for 0.5 second before continuing the process?</p> <p>thanks!</p>
[ { "answer_id": 541800, "author": "Johannes Weiss", "author_id": 55925, "author_profile": "https://Stackoverflow.com/users/55925", "pm_score": 3, "selected": false, "text": "<p>In POSIX there is</p>\n\n<pre><code>usleep(500);\n</code></pre>\n\n<p>and</p>\n\n<pre><code>nanosleep(...);\n</c...
2009/02/12
[ "https://Stackoverflow.com/questions/541784", "https://Stackoverflow.com", "https://Stackoverflow.com/users/65141/" ]
Is there a wait statement in c-component? for example, wait for 0.5 second before continuing the process? thanks!
In POSIX there is ``` usleep(500); ``` and ``` nanosleep(...); ``` have a look at the manual of `usleep(3)` and `nanosleep(2)`. **EDIT**: `nanosleep` seems now to be the way to go, `usleep` is even deprecated in `POSIX.2008` according to its manpage!
541,786
<p>I am trying to set the <code>MaxLength</code> property on a <code>RichTextBox</code> but it does not seem to work.</p> <p>Any ideas what might be happening?</p>
[ { "answer_id": 907862, "author": "Community", "author_id": -1, "author_profile": "https://Stackoverflow.com/users/-1", "pm_score": 0, "selected": false, "text": "<p>Add this code in yout KeyDown Event.</p>\n\n<pre><code>private void rLetter_KeyDown(object sender, KeyEventArgs e)\n{\n ...
2009/02/12
[ "https://Stackoverflow.com/questions/541786", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1388553/" ]
I am trying to set the `MaxLength` property on a `RichTextBox` but it does not seem to work. Any ideas what might be happening?
The fundamental problem is that the WPF RichTextBox doesn't have a MaxLength property - unlike the Windows.Forms one. Here's an improvement on @jhony's anwser. If you catch the PreviewKeyDown event and check the length, you also need to allow the user to press Delete and BackSpace after hitting the limit. ``` //...
541,789
<p>Assume that I have a dropdownlist with 2 items and, by default, the first item is selected. If I select the click the first item in the dropdownlist, is there a way I can get the SelectedIndexChanged() event to still fire?</p> <p>I thought I could do it by setting the SelectedIndex of the dropdownlist to -1, but th...
[ { "answer_id": 541814, "author": "GregD", "author_id": 38317, "author_profile": "https://Stackoverflow.com/users/38317", "pm_score": 2, "selected": false, "text": "<p>Just out of curiosity, is your first item supposed to be a selectable item or is it something like, \"select something be...
2009/02/12
[ "https://Stackoverflow.com/questions/541789", "https://Stackoverflow.com", "https://Stackoverflow.com/users/33690/" ]
Assume that I have a dropdownlist with 2 items and, by default, the first item is selected. If I select the click the first item in the dropdownlist, is there a way I can get the SelectedIndexChanged() event to still fire? I thought I could do it by setting the SelectedIndex of the dropdownlist to -1, but that didn't ...
Note: This is based on the updated content of the question. Let's say you have one drop down list and one listbox (dropdownlist1 and listbox1) You can set up your initial drop down list in your page\_load event as such: ``` dropdownlist1.items.insert(0, "----Select Sort Method----") dropdownlist1.items.insert(1, new...