
3xodus
Avatar/Signature-
Posts
47 -
Joined
-
Last visited
About 3xodus
- Birthday 08/05/1987
Personal Information
-
Occupation
IT Student
-
Visual Studio .NET Version
VS .NET 2003, 2005 Express
-
.NET Preferred Language
C#
3xodus's Achievements
Newbie (1/14)
0
Reputation
-
Argh - sorry about this PlausiblyDamp - I *think* you're right on the money. I was combining two different thoughts when I tried this out - it's been a hell of a day :), I'll try again with a clearer head in a few minutes. Thankyou very much ;)
-
It is almost, and I believe I've tried it this way at some point. The problem I have here (my fault - I didn't mention this) is that if I have a function in ClassB or ClassC (and ONLY ClassB OR ClassC) then the ClassA that I'm left with doesn't have access to it - I can only use this as an instance of ClassA with ClassB or ClassC overriden functions - hopefully of course I'm missing something. In the C++ version as the ClassA pointer was pointing to an instance of, for example, a ClassB instance, I could access public functions within ClassB. An example might be, if I were to change the existing switch statement: [color=#0600ff]switch[/color][color=#000000]([/color]someInteger[color=#000000])[/color] [color=#000000]{[/color] [color=#0600ff]case[/color] [color=#ff0000]1[/color]: p_classA = [url="http://www.google.com/search?q=new+msdn.microsoft.com"][color=#008000]new[/color][/url] ClassB[color=#000000]([/color][color=#000000])[/color]; p_classA->writeLetterB(); [color=#0600ff]break[/color]; [color=#0600ff]case[/color] [color=#ff0000]2[/color]: p_classA = [url="http://www.google.com/search?q=new+msdn.microsoft.com"][color=#008000]new[/color][/url] ClassC[color=#000000]([/color][color=#000000])[/color]; p_classA->writeLetterC(); [color=#0600ff]break[/color]; [color=#000000]} if(p_classA is ClassB) p_classA->writeLetterB(); else p_classA->writeLetterC(); [/color]
-
I have some C++ code that I wrote while at Uni (I'm in a year work placement at the minute) that's along the lines of: ClassA* p_classA; ClassB* p_classB; ClassC* p_classC; switch(someInteger) { case 1: p_classB = new ClassB; p_classA = p_classB; break; case 2: p_classC = new ClassB; p_classA = p_classC; break; (.. and so on..) } p_classA->Something(); I came back to look at it as it does what I want to do at work in C# - that is to work with either ClassB or ClassC without knowing which, via a pointer of ClassA (which both ClassB and ClassC derive from), upcasted from a ClassB or C instance. Is this even possible now in C#? I've read a little about how C#'s pointers differ from C++, and it seems not. All 3 classes are will be my own, but would contain managed properties such as strings and integers. Is there another way I can approach this? Now sure how well I've explained what I'm trying to do either. Thanks,
-
Joe Mamma: Hmm, I already have the modifiers on the controls I wanted to access set to Public. I didn't know that was a bad thing but it didn't work anyway, so I'll set them back to private. Your other solution does seem nice, but I don't think I can use that - on my Form1 there are several images and several labels which can be modified from Form2. Form2 has controls to move and resize images, and change the font, forecolor and textalignment of labels. This is why I was hoping to be able to just use firstForm.lblLabel.Location = new Point(x,y) and so on to change properties. Out of curiosity, what is the disadvantage / bad reasons for having the modifier property "public"? Cags: That's what I've read yes. I've seen one or two VB.NET example on these forums about using constructors, but I can't make sense of how to use them (where is the constructor? what code can I add to it/what are good times to use the constructor? - that's what I'm about to look up though) Maybe learning about constructors would be a good thing (I'm about to search MSDN) but it really seems to me that it would be overkill for this purpose. I just don't understand why it's so easy to do SecondForm frmTwo = new SecondForm(); frmTwo.txtBox.Text = "whatever"; but when I want to access properties on the first form from the second one, I can't use the same method. It just seems odd to me :| By the way, I just tried on Form2, Form frm = this.Owner;, and with that I can now access Form1's properties, but none of it's controls (so I can do frm.Text = "test"; but not frm.txtBox.Text = "test";. ) Am I on the right lines there or is it wishful thinking? Thanks guys :)
-
*sigh* I'm almost embarrased to ask. This is in C# for Visual Studio 2005 by the way. I've spent a few hours last night and literally *hours* trying to figure this out today, and can't for the life of me get it to work. There's a fair amount of threads on this already, but the majority deal with accessing controls on Form2 from Form1, which I can do fine. What I'm having problems with is accessing properties on Form1 from Form2. That first thing I thought was just: Form1 firstform = new Form1(); firstForm.txtBox.Text = "test"; But it dosent work, and as I understand it the reason it dosent work is that I've created another instance of Form1 and I'm accessing *that*, not the existing one. The only other solutions I've found were for VB .NET and involved adding code to the 'constructor'. I couldn't find any information about how to get this to work for C#, is that what I should be looking for? Any help appreciated, thankyou :)
-
Wow, that's a shame. I kindof expected it, since I've seen nothing about it elsewhere either. I guess I'll make my own version. Thanks anyway guys! :)
-
Hi, Is there any way I can limit the fonts shown in the fontDialog component to specific fonts? I like being back to set label.Font = fontDialog.Font; so I'd like to use the fontDialog if possible rather than creating my own, but I can only allow certain fonts to be shown. I haven't been able to find this anywhere, does anyone know if it's possible? Thanks :)
-
C# - Simple question. Regarding ListView with multicolumns
3xodus replied to EFileTahi-A's topic in Windows Forms
If you just want to access for example the second column, you can do something like: listView1.Items[0].SubItems[1].Text = "Whatever"; or depending on your situation, you could use the Key, which you would add at the same time as adding the item. Then to access the second column you could do something like: listView1.Items["ItemKey"].SubItems[1].Text = "New Text"; I'm currently writing a UI for an online gaming service, and I'm showing the users ping next to their username in a listView. Whenever I add a user to the listview, I also add their username as the key, which makes it easy for me to update their ping (and other details) whenever I want, by doing listView.Items[string UserName].SubItems.blah... Hope this makes sense :) -
C# - Simple question. Regarding ListView with multicolumns
3xodus replied to EFileTahi-A's topic in Windows Forms
Hi, This is C#, but the idea is of course the same for VB .NET or whatever language you use: listView1.Items.Add("Item 1").SubItems.Add("SubItem 1"); Will add "Item 1" to the first column, and "SubItem 1" to the second column. You can add .SubItems.Add.. etc etc for as many columns as you have :) -
Thanks for your thoughts, though my treeview is more than wide enough. The treeview's width is 197, much wider than any of the nodes. I've tested with nodes 1 character in length, and the result is the same. I am now fairly sure that setting the .Scrollable property to true at runtime just adds both scrollbars regardless of the contents of the treeview. Since I'm using C# 2005 beta 2, I'm hoping that the option is added in the final release to choose scrollbars (maybe boolean treeView.HScrollable and treeView.VScrollable) though it's not such a big deal.
-
Hi again :) I've spent too much time reading around for information on this, and trying for myself.. I know it's probably something obvious that I'm not going to find.. I have a TreeView that scrolls vertically due to the amount of nodes, but *dosen't* scroll horizontally as there are no nodes wide enough to need it. However as a part of my app I have to set TreeView.Scrollable = false;, and later on, back to = true;. When Scrollable = true again, there's a vertical and horizontal scrollbar. None of the nodes have changed, they're all still far from needing horizontal scrolling. It seems that setting the .Scrollable property to true at runtime just automatically adds both scrollbars. As a side not, the horizontal scrollbar won't even actually scroll. Just to show how pointless it is that it even appears :) Is it possible to get rid of the horizontal, and leave the vertical one there? I can't see any properties for this, but I'm hoping there's something... Thanks for any info guys ;) [EDIT @ 19th July, 21:30] I've still not found anything on this unfortunately, however my problem is solved as I've found an alternative way of doing it... I'm still interested to see if this is possible though, if anyone knows.
-
penfold69 - that's one Idea I was considering, though I didn't get round to trying it. I wanted to do it through code if I could. Joe Mamma that is perfect, thanks. Can't believe I din't think of .Parent :( Thankyou both :)
-
Hi, I'm writing a user interface for an online gaming system (found at TeamXLink.co.uk - it allows you to play XBox, PlayStation 2, Gamecube, PSP and Nontendo DS games online). The XLink engine, which does all the work tunneling packets over the Internet) is seperate from the UI, so basically you can write a UI in any language you like, so long as you communicate between the UI and engine correctly. Anyway, onto my problem - I have a treeview populated with a list of online users (tvChatUsers) and a tabControl (tabPrivateMessages). I want to add a new tab to the tabControl when a user is double clicked on, the tab should contain a button, richTextBox and a textBox. I have the following code to add a tab: TabPage PMtab = new TabPage(e.Node.Text.ToString()); tabChat.TabPages.Add(PMtab); (e.Node.Text contains the users name) That works fine, and adds a tabPage to the tabControl with the users name as it's .Text property. The part I'm having a problem with is adding a button and textBox to the tabPage container. I tried: TabPage PMtab = new TabPage(e.Node.Text.ToString()); Button PMbutton = new Button(); PMbutton.Text = "Send"; PMtab.Container.Add(PMbutton); tabChat.TabPages.Add(PMtab); But got the error "Use the new keyword to add an object instance." on the second to last line. I don't see how to use the new keyword here - I thought my first two lines were creating the object instances? Also is it possible to name the button and textBox? - I was hoping to include the value at e.Node.Text in the name so that I know which button is being clicked - which user to send the message to. Thankyou for any suggestions ro links :)
-
Hi I believe this is the site ThePentiumGuy was refering to, though I've never used it. http://squishyweb.com/ware/products.asp?q=squishysyntax
-
GMail seems quite picky - I send my work to and from college in .zips 3 times a week, every week and I've not had a problem at all.. But I have a few friends who can't send their work in zips and have to change the extension as Denaes said.