Answer Questions
Elaine CC cannot set attributte name of checkbox
hi, Why can I not decide the name of my "Name" attribute of a checkbox! HtmlInputCheckBox checkbox = new HtmlInputCheckBox(); checkbox.Attributes.Add("name","ChangedText"); checkbox.Attributes.Add("id","2"); this is the output <input name="_ctl1" type="checkbox" id="2"/> why _ctl1 please can anyone help with this issue thanks in advanced.:) Now that you can change the name, can you use something different to work as the unique id after the name Like some new attribute You can set the name, but then the name and id are going to be the same. The code to do that is: checkbox.ID = "C ...Show All
Chaman Zinga Problem With Signed Byte Support In C# To Match Java Generated Hash String
Right now I'm leaning towards that this is a issue dealing with Java having the byte type being signed and in C# byte by default is unsigned. I'm led to believe that this is what's preventing me to match any MD5 hash generated by Java regardless of what encoding I use in C#. For example this Java code as seen here: string pswd; public String getPswd() {return pswd;} public void setPassword(String passwd) { MessageDigest sha = MessageDigest.getInstance("MD5"); byte[] tmp = passwd.getBytes (); sha.update(tmp); pswd = new String( sha.digest()); } public static void main( String [] args ) { Encrypt e = new Encrypt(); String psswd1 = "ididnot"; e.setPassword( psswd1) ; System.out.println( ...Show All
blackghost Control change causes IDE to crash.
This is related to my previous post on how a rebuild causes the IDE to crash. I have more info, including some debbuger output from the memory dump that is created when the IDE crashes. First the circumstances that cause the crash. I wrote a WinForms Control. It can be dragged into the designer and used like any other control. When it is used in projects that are not written using the designer, they build and execute just fine. The problem comes when it is open in the designer. It causes a crash any time anything changes the underlying code enough to cause the designer to refactor things. If I try to build a project that has the control in it, the IDE crashes. If I build the .dll containing the control and the control is open in another de ...Show All
G20 Is there a event for Minimize button clicking?
What I want is that clicking the Minimize button in the application's titlebar to hide it (this.Hide();) but not just minimize it. So I m looking for a event in VC# for the clicking on Minimize button to do that but I failed. Any help will be appreciated! Use the Form_Resize event. If the form windowstate = minimized....then this.hide(); Cool, it works. Thanks! private void Form1_Resize(object sender, EventArgs e) { if (WindowState == FormWindowState.Minimized) { this.Hide(); } } ...Show All
mario.muja combobox selectedindex issue
I am initializing ComboBox in constructor of form before form load with following code comboBox.datasource=arrayList comboBox.displayMember=”displayString”; //property I have in collection object comboBox.valueMember=”code”; //Property I have in collection object comboBox.selectedIndex=2; Now when I run application combo box still displaying 0 th index item instead of 2 nd index item. Does any body know about this issue I did that but didn't work. This was a problem in .NET 1.1 , I tried same code .NET 2.0 and everything works fine. So thanks for your reply. It has to do with the fact that the combobox isn't visible or it's parents. ...Show All
Alex Foygel Delegates and events
Hi, I have been playing around trying to get an understanding of delegates and events - I would like to know if there is any difference between how the following 2 lines of code function ie: public delegate void NotifyFrm1 ( Object sender, ValueUpdatedEventArgs e); public static event NotifyFrm1 NotifyFrm1Action; as compared to: public delegate void NotifyFrm1 ( Object sender, ValueUpdatedEventArgs e); public static NotifyFrm1 NotifyFrm1Action; I get exactly the same results by ommitting the word event. thanks -Barb the difference between an event and a delegate is one of guarenteed persistance to the obvserver. events a ...Show All
gafferuk Two Questions (yes I have googled it)
1) Is it possible to create a custom event Like when something happens, ex. when textbox1.text equals Dumbo, raise an event, with the ability for an event handler that will handle that event 2) In Visual Basic, you can use handles button1.click, button2.click etc. etc. to handle multiple events with one handler, what's the C# equivalent I already know that. But I need to create the event first... 1) yes you can. Example, delcare an event and delegate at the top of the form: public delegate MyEvent TheEventDelegate(); public event TheEventDelegate OnEventSomething; //create a handler: this.OnEventSomething += new MyEvent(Form1_OnEventSomething); //Example, we are creating an event in Form1, aft ...Show All
Rattlerr Checking for registry value
How will I do a code that will check if a certain registry value is currently in the registry, if not create it. I did somethign like this but I get an error: if (Microsoft.Win32.Registry.CurrentUser.OpenSubKey(@"Software\Microsoft\Windows\CurrentVersion\Run").GetValue("CA", "C:\\windows\\consoleapplication2.exe"); == false) { Microsoft.Win32.Registry.CurrentUser.OpenSubKey(@"Software\Microsoft\Windows\CurrentVersion\Run", true).SetValue("CA", "C:\\windows\\consoleapplication2.exe"); } Oh, thank you but can someone provide a line of code I am kind of lost in reading the links above. I think I am missing something. Thanks. Try to modify false to be null if (Microsoft.Win32.Registry.CurrentUser.OpenSubKey(@&qu ...Show All
yanyee toolStrip with Database connection
i have a combobox on my toolStrip How can I populate with data from a database what is npg_command I assume looking at it that it looks an awful lot like SqlCommand - am I correct ExecuteReader() has an overload of nothing or an overload of the CommandBehaviour - you can remove the Commandbehaviour enum if you like, this is just the way I do things but make sure you close the connection after you have used it, as I have shown and which is in your code. its not available for the toolstripcombobox I'm afraid. The only thing you can do in this situation is once you have filled a dataset, to go through each row/column of data and add it to the toolstripcombobox. ok i see, its different to what I t ...Show All
hrubesh System.Collections.Generic.Dictionary(T(string), T(int)) throws Index was outside the bounds of the array !!????
Hi, Anyone have any clue as to why the hell System.Collections.Generic.Dictionary could possibly throw an exception of type IndexOutOfRangeException This is what my event logger has recorded. this is the exact section in the code. 151: if (bNr) { 152: lock (sendlock) 153: Sent.Add(tt, 0); 154: } tt being a string of value 4103-1 At that point there was 1 other element in the dictionary 4103 is a sequential number that increments via this code prior the code above. int seq = Interlocked .Add( ref _seq, 1); string tt = seq.ToString() + "-" + EndPointId; Below is the exception ! Index was outside the bounds of the array. ----------------- Stack: at System.Collections.Generic.Dictionary`2.Insert(TKey key, ...Show All
pessi print contents of multicolumn listview box - arghh!
I have a multicolumn listview box. I have looked all around for some basic instructions on how to print its contents and remained baffled. I would appreciate a the simplest example or url to simple example on how to do this. Should I print the listview box to a text file, then use stream reader appreciate your help! david Looks like some of the code got jumbled on my cut and paste... Code should read... printableListView.Columns.Add("Column 3", 100, HorizontalAlignment.Left); // Wrap results. If multiple entries in Result column, then they are separated by a ";". NOT printableListView.Columns.Add("Column 3", 100, HorizontalAlignment.Le ...Show All
Kallex Search For Files?
How can I search a directory for files I have tried DirectorySearcher, but that doesn't do anything. Is there a way Like Directory.GetFiles("""""); Thanks, use the Directory.GetFiles class: string[] theFiles = Directory.GetFiles( path , searchPattern); example: string[] theFiles = Directory.GetFile(@"C:\my folder", "*.jpg"); would get me a list of jpg files from the directory my folder under the C:\ drive Example should be string[] theFiles = Directory.GetFiles(@"C:\my folder", "*.jpg"); ...Show All
Simon Jefferies How to trigger a window service to start every 10 secs
Hi all, I would like to know how can I trigger a window service "MyService" to start every 10 secs. Thanks Exactly, use a timer and call that method that you want to execute. Declare a timer object System.Timers. Timer t = new System.Timers. Timer (); in the windows service OnStart method, t.Interval = 10000; //10 Seconds t.Start(); t.Elapsed += new System.Timers. ElapsedEventHandler (t_Elapsed); // Adds an event handler on runtime Now just add the code to the event handler. Hope it helps I did the same but my timer doesnot seem to work properly, as its elapsed event is not being called at specified interval. Is ...Show All
GradProd Determining if a generic Type implements ICollection
Hi, I need to know if MyProperty returns an ICollection<T> for any T. Given a PropertyInfo instance that has a PropertyType of an IList derivative, for example. public IList<MyType> MyProperty { get { return mycollection; } } I am iterating through the properties of the type, and would like to know which properties implement an ICollection of any kind. Basically I need to know if MyProperty returns an ICollection<T> for any T. Is there any way of finding this out My problem is that I cannot seem to find a way of determining if the property returns a collection of 'any kind' I have to know the exact type of the property which I don't really know at runtime. I have tried typeof(IList<object ...Show All
KitGreen error when binding a property of custom business entity to form control
When I define my class like: public class ProductEntity { private int productID; // Public properties, to expose the state of the entity public int ProductID { get { return productID; } set { productID = value; } } ...... then to bind the ProductID to my textbox.Text in a form I do: textBox1.DataBindings.Add("Text", myProductObject, "ProductID"); But I get error: Object reference not set to an instyance of an object . But When I initialize the value of productID like in private int productID=0; that fixes the problem My question: I don t see why I should initialize that value. Is there a way not to get the error without initializing productID . and what s a good practice ...Show All
