Obviously so and it is being checked for. I am assumming that the Toolstrip's internal Items collection is not be intialized, but when I go and review the code for the Toolstrip class, you will see that the Items property instantiates the collection if null. Therefore, there should be no null value. Considering that the Designer uses reflection, I am wondering is there is a code path that is not being called in design-time. Any thoughts?
xfitr2
Posts
-
Expose Property of Constituent Control in UserControl -
Expose Property of Constituent Control in UserControlI have a custom control derived from the UserControl class. I have three controls in the container; label, treeview, and toolstrip. I want to expose the Items collection of the toolstrip so that the user can add objects at design-time. When I add the custom control to a form and click the exposed Items collection in properties, I get the following error message: "Value cannot be null. Parameter name: value." I've exhausted all my resources and would appreciate any help anyone can give on this issue. I have provided my property code snippet I used in my custom usercontrol.
private System.Windows.Forms.ToolStrip toolstrip; ... public ToolStripItemCollection Items { get { if (toolstrip == null) { toolstrip = new ToolStrip(); } return (toolstrip.Items); } set { toolstrip.Items.Clear(); foreach (ToolStripItem obj in value) { toolstrip.Items.Add(obj); } } }
-
Enable/Disable Button through javascript [modified]I have a asp.net page where my button is enabled or disabled depending on whether two textboxes are properly filled out. I enable/disable the button through the onchange events of the textboxes. Once button is enabled and I click it, the postback seems to have disappeared because it does nothing. I enable/disable the button like this:
function checkBuild() { document.getElementById('sMsg').innerHTML = ''; checkBAL(); checkINI(); if ((checkBAL()) && (checkINI())) { **document.form1.btn1.disabled = false;** checkWarning(); } else { **document.form1.btn1.disabled = true;** } }
I've read that in order for the button "btn1" to postback, I must have it enabled onLoad which I have done for testing. Therefore, if I click the button before my javascript fires, it works; only stops working once my checkBuild() function is called by the textboxes javascript onchange event. Can anyone help with this issue? Many thanks.
modified on Monday, September 22, 2008 10:31 PM
-
Insert statment for multiple tablesIn reponse to Michael & Vikram, yes, you should be using transactions on multiple statements. The example I provided to you was based on your original post. If your intentions are not alwasy to insert records, then you will need to modify the stored procedure to check for the Roles, Managers, etc. If found then update your employee table. You will need to know SQL. If you are using a Listbox or Combobox, you can also save the PK in the control collection and just pass that to your stored procedure. There are many ways to kill this bird, it just depends on your requirements.
-
Threaded FormThank you for the suggestion. My problem though is trying to get the form to Hide/Close once the user clicks/types outside the form. Is there an event fired when this happens that I am not aware of or do I need to use a global hook? If I was to use a hook, how do I know that the source of the hook was not within the form?
-
Insert statment for multiple tablesThat was a SQL statement for creating a stored procedure in SQL Server. Once you create it in SQL Server, you can then call it using a class like SqlDataReader and use the method ExecuteNonQuery. Don't forget to add your parameters!
-
Insert statment for multiple tablesCREATE PROCEDURE sp_InsertEmployee @Firstname nvarchar(50), @Lastname nvarchar(50), @Role nvarchar(50), @Manager nvarchar(50), @Division nvarchar(50) AS BEGIN SET NOCOUNT ON; INSERT INTO EMPLOYEES (FIRSTNAME, LASTNAME) VALUES (@FIRSTNAME, @LASTNAME) INSERT INTO [ROLE] ([ROLE]) VALUES (@ROLE) INSERT INTO MANAGER (MFIRSTNAME) VALUES (@MANAGER) INSERT INTO DIVISION (DIVISIONNAME) VALUES (@DIVISION) END GO
-
Rijndael Encryption Question..I found this article very useful when I had to write an encryption program for my company. http://www.developerfusion.co.uk/show/4647/4/[^]
-
Determine Double-Click / Middle Click using low-level mouse hook?Check out this article: http://www.codeproject.com/csharp/globalhook.asp[^] It has a MouseActivity Event that you can see which mouse button was clicked.
-
Insert statment for multiple tablesYour best solution would be to create a stored procedure and call it within your code "ExecuteNonQuery." The stored procedure will do all the work of inserting the records into the proper tables. As far as I know, there is not a way, with SQL Server, to insert into multiple tables with one INSERT statement. This also gives you the ability to do error checking on the back-end.
-
Threaded FormI am having trouble with closing a form created in a seperate thread. This is what I am trying to accomplish: I have a program that runs in the taskbar. When a user double-clicks a key, a form is created in a new thread and is shown on top of all other forms. When the user clicks anywhere outside the form, the thread will close, but the program will continue to run in the background. This is similar to the Google Desktop functionality. The code works the first time the form is created in a new thread, but if the form has been closed once, you have to click on the form to make it active and then click outside of it before it will close. I have tried using the Deactivate and LostFocus events, but they both only work the first time the form is shown. Any suggestions would be greatful. I have included a snippet of code below.
public class MyClass { private Thread _thread; private FMain _fmain; private UserActivityHook _keyhook; public MyClass() { _keyhook = new UserActivityHook(false, true); _keyhook += new KeyEventHandler(KeyDoubleClick); } private void KeyDoubleClick(object sender, KeyEventArgs e) { if (e.KeyValue == 163) { _thread = new Thread(new ThreadStart(OpenForm)); _thread.Start(); } } private void OpenForm() { _fmain = new FMain(); _fmain.Deactivate += new EventHandler(form_Close); _fmain.LostFocus += new EventHandler(form_Close); _fmain.ShowDialog(); } private void form_Close(object sender, EventArgs e) { _thread.Abort(); } }
References: The UserActivityHook was fortunately posted by George Mamaladze; http://www.codeproject.com/csharp/globalhook.asp[^] -
Notepad ReplacementNotepad++ is the way to go.
-
Do you guys use wikis?I set one up for my company and we have been using it to document projects, network configurations, company standards, etc. We still like to write our docs in Word for each stage of the lifecycle, but wiki is a quick way to share notes during development of changes, snags, etc that need to be formally documented later on.
-
Do you guys use wikis?I set one up for my company and we have been using it to document projects, network configurations, company standards, etc. We still like to write our docs in Word for each stage of the lifecycle, but wiki is a quick way to share notes during development of changes, snags, etc that need to be formally documented.
-
OLAP DesignThis book is great. Thanks.
-
OLAP DesignMy company is using SQL Server 2000 for our OLTP DBs and I have been writing reports using SSRS. The time has come for us to start a datawarehouse because of the amount of processing some of these reports entail. I have done research online about OLAP design and concepts, but I would really like recommendation of a good book that is full of case studies, design examples, etc. Many thanks.
-
records with their row numbers in a tableI do not recommend this but you could create a insert/delete trigger that loops through the recordset and inserts the new value. This is a performance hit. A sample trigger is below. You must have a primary key on the table to do this. I am confused of why you need to reference the rownumber. It has no significance. If you dont mind a few holes here and there after you have deleted a record, use an Identity column.
CREATE TRIGGER dbo.trg_Count ON dbo._TEST AFTER INSERT, DELETE AS BEGIN SET NOCOUNT ON; DECLARE @PKEY UNIQUEIDENTIFIER DECLARE @I BIGINT IF ((SELECT trigger_nestlevel()) = 1) BEGIN DECLARE TRG_TEST_CUR CURSOR FOR SELECT [GUID] FROM _TEST OPEN TRG_TEST_CUR FETCH NEXT FROM TRG_TEST_CUR INTO @PKEY SET @I = 1 WHILE @@FETCH_STATUS = 0 BEGIN UPDATE _TEST SET ID = @I WHERE [GUID] = @PKEY SET @I = @I + 1 FETCH NEXT FROM TRG_TEST_CUR INTO @PKEY END CLOSE TRG_TEST_CUR DEALLOCATE TRG_TEST_CUR END END GO
-
Problem with XMLHTTPRequest [modified]To answer my own problem. It seems that I will have to create 'virtual threads' in javascript to handle the callback event. http://www.developer.com/lang/jscript/article.php/10939_3592016_2[^]
-
Problem with XMLHTTPRequest [modified]I think that I will just build an xmldoc and send that to the asp page. This way, there will only be one XmlHTTPRequest sent per user click even if there are multiple items selected.
-
Problem with XMLHTTPRequest [modified]Thank you for your response. I just tried your suggestion and now it will process the first request in the for loop and then stops.