
Cags
Avatar/Signature-
Posts
699 -
Joined
-
Last visited
Content Type
Profiles
Forums
Blogs
Events
Articles
Resources
Downloads
Gallery
Everything posted by Cags
-
You can check the browser being used with some kind of scripting language, php, javascript or asp. I'm assuming that since your on a .Net forum you'd be looking at using asp, a quick search of google revealed the following http://www.webmasterworld.com/forum45/385.htm
-
I realised the object was disposed rather than null but wasn't sure how to check for this (I've since realised controls have an IsDisposed property). What I was suggesting was to simply create the frmHistory when you create frmApp, this way you don't need to worry about whether it is created or not you simply call frmHistory.Show(), if the Form is already visible this will have no effect. Alternatively you could do as PlausibleDamp suggests and declare the form outside of the routine then add if(pagefrmHistory == null || pagefrmHistory.IsDisposed) to your mnDBInfo_Click event. NB. Its important to check if the Form is null before checking if its disposed, as you can't check the .IsDisposed property of a null Form.
-
The common way most people use images in the way you talk about is to store the images on the web and adding the image to the email through the use of a link. Obviously this would require webspace and may not be what your looking for, but I thought I'd suggest it just in case.
-
I originally thought the same thing so I gave it a quick test. By creating the frmHistory in the constructor of frmApp. Then whenever I clicked a button I checked if this object was null if it was I added code to re-create it. The problem was that when the frmHistory is closed the original object doesn't appear to be null. Maybe I missed something obvious I don't know but the way I got around it was todo this. public class frmApp : System.Windows.Forms.Form { frmHistory pagefrmHistory; public frmApp() { pagefrmHistory = new Form2(); } } public class frmHistory : System.Windows.Forms.Form { public frmHistory() { } private void frmHistory_Closing(object sender, System.ComponentModel.CancelEventArgs e) { // add this method as the form closing event // essential prevents it being closed, simply hides it from view this.Hide(); e.Cancel = true; } }
-
I don't know if this will help at all, it depends what your trying to achieve. But the Control.PointToScreen() function will turn an application based point into a point relative to the screen. private void Form1_MouseDown(object sender, System.Windows.Forms.MouseEventArgs e) { Point pScreenRel = this.PointToScreen(new Point(e.X, e.Y)); }
-
I'm not sure exactly what your trying to achieve but the following article may help, it discusses application specific paths. Its in the c++ section, but I can't see that mattering. http://www.codeguru.com/Cpp/W-P/dll/article.php/c99
-
RadioButton event _CheckedChanged running funtion twice [C#]
Cags replied to Shaitan00's topic in Windows Forms
Simply use the Event browser from the visual studio IDE and select that method, or add the following line to the constructor. this.radioButton1.CheckedChanged += new System.EventHandler(this.CheckChanged); NOTE: - Obviously you'll need to do the equivalent of that line for all radiobuttons, but using the event browser is a far easier option. -
How one form can tell another to perform an action [C#]
Cags replied to Shaitan00's topic in Windows Forms
If I'm understanding your question correctly this is what you are attempting todo. You have 2 forms, one called frmApp and another called frmHistory. The frmApp has a method RefreshGUI which you wish to call from the frmHistory. The way I would do this is to pass an instance of cApp into the constructor of cHistory, then whenever you create frmHistory pass frmApp to it. Then simply create a local reference so that you can call frmApp.RefreshGUI() from anywhere on frmHistory. public class cApp : System.Windows.Forms.Form { private cHistory frmHistory; public cApp() { frmHistory = new cHistory(this); } public void ShowHistory() { frmHistory.Show(); } } public class cHistory : System.Windows.Forms.Form { private cApp frmAppRef; public cHistory(cApp frmTemp) { frmAppRef = frmTemp; } public void ButtonClicked() { frmAppRef.RefreshGUI(); } } -
Select vs. If/elseif statements for determining type
Cags replied to ballisticnylon's topic in General
Quite a long time ago I asked a similar question. To see the suggestions I got take a look at this thread http://www.xtremedotnettalk.com/showthread.php?t=85039 -
RadioButton event _CheckedChanged running funtion twice [C#]
Cags replied to Shaitan00's topic in Windows Forms
I would create a single method similar to the one below and assign it to the CheckedChanged even of all of these checkboxes. private void CheckChanged(object sender, System.EventArgs e) { if(((RadioButton)sender).Checked) RefreshGUI(); } -
Generally speaking if the data will always be entered in the same logical order the best option would be to use the next button idea as it is more user friendly. Data that could be input in any order would be better suited to be displayed in tabs allowing the user to easily switch. I notice from your post you were planning on using multiple forms with the next button option. I personally find an easier way of doing this is using panels. And having next / back buttons call the BringToFront() method of the relevant panel. Whether this is the best method I don't know, but its the way I have found easiest in the Past. Obviously an easier option is to use a tab control that allows you to not draw the tab section, but I don't believe this is possible with the standard version.
-
How to set the Starting Index on a combobox (or similar) control?
Cags replied to Denaes's topic in Windows Forms
Ahh I understand what you mean now, you wish to change the value from the visual ide. As you point out there doesn't currently appear a way todo it. Lucky it shouldn't take you long to inherit the control and add the functionality, its just annoying todo. As for what marble_eater says, I can't see any real reason it would be quirky as long as the value setting the default is an integer. As you mention it is possible to set other styles to a value not in the list, but since the default value will only ever be set at design time, and is only ever likely to be a value in the list, this shouldn't cause any trouble (unless i'm missing the point somewhere which is quite possible). -
As PlausiblyDamp says it would be hard to tell you the exact problem without seeing the code, however here is an example of code that should do the job Dim myAssembly As System.Reflection.Assembly = System.Reflection.Assembly.GetExecutingAssembly() Dim myStream As System.IO.Stream = myAssembly.GetManifestResourceStream("projectname.image.png") Dim image As New Bitmap(myStream) BackgroundImage = image After adding the image to the project you must ensure that its property 'Build Action' to 'Embedded Resource'. On a side note if the problem is that only part of the image is drawing and parts of whatever is behind the form, this is due to the transparency in the png. The png will need editing to prevent that from happening.
-
I've been having a poke around the various methods offered, as it is an array it has a method 'Clone' I've not throughly checked this out yet, but would this not create a non-referenced copy of the array?
-
How to set the Starting Index on a combobox (or similar) control?
Cags replied to Denaes's topic in Windows Forms
I may be completely misunderstanding the question, but can't you just set the SelectedIndex property to select a specific item. -
Thanks for confirming that, from the result I was getting I was assuming this was the case but wasn't sure. So if both those methods simply create pointers when working with arrays of classes, what is the easiest way to create a seperate copy of an array. I basically need two arrays containing identical classes so that I can perform a set of operation on one array, but still have an array containing the initial states.
-
Hi everyone, its been a long time since I've posted, but here goes. I've been recently working on an application and I've hit abit of a snag. I seem to be hitting some sort of a problem which appears to be something todo with references. If I create 2 blank arrays and then set them both equal to a third array, any changes I make to any of the arrays reflects in the others. int[] a = new int[4]; int[] b = new int[4]; int[] c = new int[] { 1,2,3,4 }; a = c; b = c; b[0] = 2; After running this section of code its obvious that a[0], b[0] and c[0] are now all equal to 2. This obviously means that by assigning the values equal I have created some kind of reference linking the objects, rather than copying the values. In an attempt to avoid this problem I tried using the CopyTo() command. So... int[] a = new int[4]; int[] b = new int[4]; int[] c = new int[] { 1,2,3,4 }; c.CopyTo(a, 0); c.CopyTo(b, 0); b[0] = 2; I thought this had finally solved my problem, as there was no longer a link between the arrays. The problem is I was only using the int arrays to simplify the method and detect what was going wrong. The actual section of code I wish to use employs arrays of custom classes. Here is an example. Square[] a = new Square[iDimensions*iDimensions]; Square[] b = new Square[iDimensions*iDimensions]; arrGrid.CopyTo(a, 0); arrGrid.CopyTo(b, 0); b[2].SetValue("A"); Square is a simple class with a few properties and methods. Now as far as I can tell there is no difference in the logic from this code and the example using int arrays. However with this example the last line of code changes all 3 arrays. Boy that took alot of explaining, I just hope it makes sense. Oh btw I'm using C#.
-
Just thought i'd mention that often if you override the onpaint method and you are drawing the entire control, you can normally override the onpaintbackground (leaving it blank). Not doing this can sometimes cause flickering. I know you said you had overriden the onpaintbackground but you didn't say if you had blanked taken out the base.OnPaintBackground (pevent);
-
I'm not sure how easy this is going to be to follow but... heres my problem. 1. User clicks button for new quiz 2. Application creates instance of Quiz class 3. The constructor of the Quiz class creates a wizard form (passing in itself so the wizard can change its properties) If the user clicks cancel on the wizard form I'd like to destroy the class so that the main application knows a quiz wasn't created. The way i'm currently doing it is to set a 'Cancel' property in the Quiz class, then back in the main form checking this property and setting the Quiz class = null if 'Cancel' = true. Has anybody got any suggestions of a better way of achieving this?
-
ahh ok, thanks for the confirmation, I wasn't sure if there was just something up with these 2 pc's it just seemed odd that it worked fine in Windows XP.
-
I have noticed an alignment error on this pc when using labels, this problem also occured on the other win2k machine in the office, but not the WinXP ones. essentially what i did was create a new application and added 2 labels. I made both labels the same size, one above the other and set the text values as follows. Label1.Text = "Label1" Label2.Text = "This is a label test to check alignment" i then set the TextAlign value of both to MiddleRight. When i run this application (and indeed in VisualStudio) the text does not align perfectly on the right hand side. "Label1" is further to the right than the other string, this is made more obvious if you turn on the label border. When the same application is ran on the WindowsXP machines in this office they are identical (as you would expect them to be). I was wondering if anyone else with win2k can replicate this error... any feedback would be welcome
-
I am currently working on a project that requires me to build several clients, each for differn't platfroms (i.e. a TabletPC client, a PocketPC client, a DesktopPC client). Now each of these clients will contain essentially the same custom controls, however the controls will need todo slightly differnt things depending on which platform its being used on (i.e PocketPC client needs to show the input panel when a textbox is selected). It seems pointless writing 3 sets of controls, each with only slight differences, so is there an easy(ish) way i can add code that will only run dependent of which platform it is on. The only other solution i can come up with is writing only one set of code, but using the c# syntax [Conditional("Platform")] and try to compile 3 seperate sets of controls. (i'm not sure if this will work yet, as i've not fully explorered it) Any suggestions?
-
I'm attempting to alter an xml file. This file will have 2 main nodes in it, a Count node, and a Data node, what i wish todo is to amend a child node to the data node and increment the count node by one. At the moment i am doing this by loading it into the DOM and changing it, then using the save method. However this I know has alot of memory overheads, is there any way of doing this using the XmlTextReader & XmlTextWriter? I've played around with it abit, but can't seem to find an easy way of simply copying data from the reader to the writer.
-
I was wondering in what situations the If/ElseIf, and Switch case statements are best used. By this I mean what are the advantages and disadvantages of each one. From what I can tell they both essentially do the same thing.
-
Is anybody able to give me some example code using the Activator.CreateInstance() method. I'm really struggling to understand the information held about it on MSDN.