Answer Questions
Matthew_Stevenson Problem with Reflection: PropertyDescriptor.SetValue()
The method it supposed to take a CustomControlDesigner which has a Control contained within it. I want to do a deep copy of it, without having to keep updating the method whenever I change the attributes of CustomControlDesigner. The problem is that the method is throwing a System.Reflection.TargetException(Object does not match target type) on the line with //*** (the SetValue method) The type names that the message box shows are always identical - I assume the problem is that the one I'm setting on the returnable object is cast to 'Object'. Does anyone know what I can do to cast it to its most specific type, or fix this error some other way public static CustomControlDesigner CloneDesigner( Cu ...Show All
nharendt Make a File readable only by my application
HI, I'm developing a windows application in c# and i use video with DirectX. My problem is that i don t want the video to be readable by classic players and only by my program. I ve try to use cryptography but it take to long to charge the video. If anybody as an idea... Sorry for my english, and happy new year, Laura. Sorry, i replied a bit too quick :) i ve found what the file header info was about but i ve got 2 little questions (the last ones, i promiss). Why does visual studio doesn t let me encrypt my file with the code: FileInfo fi = new FileInfo (System.Windows.Forms. Application .StartupPath + "\\intro.avi" ); fi.Encrypt(); and could i change the file header ...Show All
a23rd Converting Date
Hi, I'm developing an app to send SMS messages and one of the requirements is the 'Send Date & Time' which I need to pass to the provider when sending the message. On my form there is a Checkbox for the user to click is they want to send the message on a particulr date and time (Send Later), if this isn't checked the message is sent using the current system date and time. For this I've been using: - System.DateTime dt = DateTime.Now; I now want to change my code to include a check to see if the user has selected to 'Send Later' and if so use the selected date from the DateEdit control and time from the TimeEdit control. The If - Else is ok, but I'm having problems setting 'dt' from the date & time controls and con ...Show All
Bryan_Ta Newbie question: Passing TextBox value in SQL query
I wrote following code, but it displays an error where I am passing the TextBox value. Please help: ---------------------------- string qFind = "Select * from FamilyType where FNM like '" & textBox1.Text & "%'"; ---------------------------- You are probably passing a string that contains an apostrophe. As a rule, you should not build your queries from strings, always try to use parameters. SqlConnection conn = new SqlConnection (myconnectionstring); SqlCommand cmd = new SqlCommandd ("select * from FamilyType where FNM like @Pattern", conn); cmd.Parameters.AddWithValue ("@Pattern", textBox1.Text + "%"); ... Edit: I just noticed you are joining your values with "&". That's VB... In C# you  ...Show All
i7hira7 Evaluating a string to call a method
I'm new to C# and for better or worse i'm trying to do things the same as in the language i'm used to (OMNIS). In the past i could do this: String s1 = "printName('John Doe')"; Test.[s1]; And the square brackets would be evaluated and John Doe would be passed to the printName method in the Test class. I have a list of methods and parameters formated as strings from an external data source. Since my data source is defining the flow of the application the calls can change. So a nice for loop with a simple string evaluation would be wonderful to have instead of a huge switch statement that evaluates the string. Thanks for the replies. I'll try to explain in more detail what i'm t ...Show All
GoDaddy Redim in C#
Hello everyone, is there a way to simulate VBs redim function in C# Thanks Redim is used to resize some array, so while working in .Net or specifically C# i would recomend you using Collections under System.Collecitons.Generics namespace. like List<T> class Dictionary<T,S> class etc example: List<int> list = new List<int>(); // create a colleciton to store int.... list.Add(1); // Add some number list.Add(2); // Add another Number. This will automatically be resized whenever you add something to it and you don't need Redim anymore here. I hope this will help. Best Regards, Rizwan aka RizwanSharp Thank you sir Check Array.Resize ...Show All
Cla82 InvalidCastException, but just in thread
Hello, I'm currently writing a program and stumbled across the following problem: I want to poll the title of a frame of a website (and react if it changes). Therefore I created a thread. But everytime I try to access the the frame count or frame title I get this InvalidCastException. But outside the thread I can access it without any problems. I tried alot of things but nothing worked. Here is the relevant current code (with some of my tries): public partial class Form1 : Form { bool tmp = true; public Form1() { InitializeComponent(); webBrowser1.Url = new Uri("http://mysite"); webBrowser1.StatusTextChanged += new EventHandler(web ...Show All
element109 Passing values into EventArgs when a button is clicked
I am currently building a shopping cart application using C # in VS2005 where there are 10 items to select from. There are 10 "Add to Cart" buttons, when clicked, will trigger a single method. That single method will either add a row (new item), or update the quantity (old item). In my existing code, i loop through each row in the DataSet to determine whether i should add a row or update a row. Is there a way to store the item information (name, description and price) in EventArgs so that when the "Add to Cart" button is clicked, the item information is passed to the single method using EventArgs I am aware that i can create my own EventArgs class that inherits the EventArgs class but is there any way to store my it ...Show All
Russ McDaniel read from Cisco router
is it possible to read the configuration stored in cisco router using C# How For this kind of devices you have normally two choices - either is is configurable by means of WEB interface - then use HttpWebRequest or it is configurable by TELNET then use TcpClient from System.Net namespace. Both is feasible, however because CISCO has quite simple command line interface on TELNET connection, I would definetely recommend you to use this. i dont think so, unless there are API's or something, unlikely however. only way would be via telnet (or its own web config page) I guess if you are connecting to it via serial cable, use the SerialPorts class in .NET 2.0 to est ...Show All
Thymen How do I calculate amount of hours using DateTime
Hi all. As the title says... how do I calculate the amount of daily hours worked by an employee I'm pretty sure this is probably basic but I'm a novice and I'm trying to write a basic app to act as a weekly timesheet, either with VC# or ASP.Net I'm using DropDownLists to enable the user to select a starting hour and a finish hour. The calculation I'm using is (12 - startTime) + finishTime I'm sure I should be using the DateTime object but that's where I'm lost. Should I be using DateTime objects What values would I use for the DropDownList Value property Any help / advice would be greatly appreciated. Thank you. Jake Yeah, that's the way I did it thanks James. I was ...Show All
desijatt What should I do? ---help...
when I'm doing a MDI application, I have to catch the event : when the child window is closed by click the control box. that means I have to do something before dispose the child. as : mdiParent is form1, the child window is cld. should I add event process and How thank you!! Add a FormClosing event: this .FormClosing += new EventHandler(Form1_FormClosing); private void Form1_FormClosing( object sender, FormClosingEventArgs e) { e.Cancel = true ; } No problem :) thanks for your help, and kindness. anybody here ...Show All
Ramanuj *Newbie* Can Parameters be added to a textbox changed or leave event?
Hi, I have sub classed a new text box class using the standard windows text box. I have been asked to add the following code to the text leave event so that my rules file when when the user leaves the control. (So that it will do this for every text box instance of this class). can i add parameters to the method, ie private void Textbox_Leave( object sender, EventArgs e, dataSet, RuleExecution) and how would they be passed in private void Textbox_Leave( object sender, EventArgs e) { if (null != ruleExecution) { try { this.ruleSetDataSet.RuleSet.Execute(ruleExecution); } catch (Exception e) { MessageBox.Show("Exception thrown \n" ...Show All
Madhu_TN Library help: a set class needed
Hi I need som tips about finding a library that is implements som sort of a set datatype. That is a collection where all members are unique. Something like the Java languages Hashset implementation: http://java.sun.com/j2se/1.5.0/docs/api/java/util/HashSet.html Thanks Regards i don't think microsoft added this support for .NET 2.0 but for 1.1 we are using Iesi.Collections from this project (http://www.codeproject.com/csharp/sets.asp). you might also want to checkout the PowerCollections " The C# and Java Hashset share just the name." C# doesn't have a Hashset (or any set implementation), it has a Hash table . One can easily implement their own set class, however, by using a Hashtable internally to track what ite ...Show All
hillrg Databound combobox.selectedvalue
Hi, I have some problems with a combobox using a datasource. The datatable only contains an id (auto number) and a description text So when i bind the data to the combobox i set the displaymember and valuemember to the description field (cause the result is save as text in the table using the combo's) When i save my data i get the selected value by using m_row.Category = ComboBox.SelectedValue When i load the data and say ComboBox.SelectedValue = m_row.Category the value aint selected, selected value stays null Hi I this case the selected value is not the value of the discription column but it is the row in which the value is: m_row.Category = ((DataRow)ComboBox.SelectedValue)["Ca ...Show All
TrD C# 2005 ignoring STAThread attribute
Greetings. I'm developing a WinForms-driven application, and I need it to use Single Threaded model for COM interop. C# 2003 worked fine with [STAThread] attribute above main() declaration. But we just upgraded our machines to VS 2005, and our application is failing due COM errors. We found C# 2005 is creating the main thread as Multithreading model, regardless the STA attribute. Any idea why is this happening . Here is a snippet of our entry point code, not complex at all. Putting a breakpoint in the first line of main(), already shows the System.Threading.Thread.CurrentThread.ApartmentState as System.Threading.ApartmentState.MTA. #region Main /// <summary> /// The main entry point for the applica ...Show All
