|
salithus posted:The DataGridView is working now. I realized I hadn't rebooted since last week You may be able to do it by doing the binding with master-detail databinding and using one bindingsource as the source for the other or something like that, instead of handling that in code. Or put the code to fill the grid in a seperate function and call it when the form loads. You're still loading it manually one time when the app starts, but it feels less icky to me than calling the event handler or setting the selected index in code.
|
# ? Jul 10, 2007 21:47 |
|
|
# ? Jun 2, 2024 14:10 |
|
salithus posted:When the app loads, it's populating the product list and starts with the first one selected, so it should have that product line's data populated, but forcing the "SelectedIndexChanged" event seems too forceful. That's sort of the issue though, isn't it? The list is starting with the index at 0, it's not changing. Is there an event you can attach to that indicates when the DataSource has changed, so that you could fire the logic in that method?
|
# ? Jul 10, 2007 22:14 |
|
code:
quote:Is there a cleaner approach to what I'm doing though? ... but forcing the "SelectedIndexChanged" event seems too forceful. If you're just trying to get the code you've placed in cbxProductList_SelectedIndexChanged to fire without calling it directly, then just move that code out to its own method. Call your new method from within cbxProductList_SelectedIndexChanged and also in place of the code snippet above. This seems overly simple though so maybe I'm just not understanding the question.
|
# ? Jul 11, 2007 01:10 |
|
Kekekela posted:If you're just trying to get the code you've placed in cbxProductList_SelectedIndexChanged to fire without calling it directly, then just move that code out to its own method. Call your new method from within cbxProductList_SelectedIndexChanged and also in place of the code snippet above. This seems overly simple though so maybe I'm just not understanding the question.
|
# ? Jul 11, 2007 01:23 |
|
csammis posted:That's the exact same process as calling the event handler directly If this is what you have: cbxProductList_SelectedIndexChanged(...) {code to run} and you change to: cbxProductList_SelectedIndexChanged(...) {foo();} foo() {code to run} Then you can just call foo() instead of cbxProductList_SelectedIndexChanged(...). I think I'm probably not understanding your problem, it seems like you're just saying you want to fire the code you currently have in cbxProductList_SelectedIndexChanged without calling it directly. edit - csammis: Just realized you weren't the person posting the problem. Please mentally change this from 2nd person to 3rd person when you read it. Kekekela fucked around with this message at 01:46 on Jul 11, 2007 |
# ? Jul 11, 2007 01:42 |
|
Kekekela posted:If this is what you have: I know what you meant, and again, it's the exact same thing as calling it directly but with the added bonus of an additional stack frame every time the event handler is called for real Kekekela posted:edit - csammis: Just realized you weren't the person posting the problem. Please mentally change this from 2nd person to 3rd person when you read it. I just figured you meant "you" as in "you in general" csammis fucked around with this message at 01:52 on Jul 11, 2007 |
# ? Jul 11, 2007 01:45 |
|
csammis posted:I know what you meant, and again, it's the exact same thing as calling it directly but with the added bonus of an additional stack frame every time the event handler is called for real
|
# ? Jul 11, 2007 01:58 |
|
csammis posted:I know what you meant, and again, it's the exact same thing as calling it directly but with the added bonus of an additional stack frame every time the event handler is called for real Yes, its the same thing and I'm not saying its right or wrong, just trying to answer his question. That said, there are certainly reasons to move your code out of the method the event handler is calling, especially if you are using the graphical IDE to develop the interface and letting it auto-generate the event handler and method for you. If its code that you can reuse it probably makes more sense in your design to have it somewhere else. For me, wherever it makes sense to have the code from a design perspective would be where it ends up going. The performance implications of an extra zero parameter stack frame, with no net increase in local variables on the stack, wouldn't be a factor. Kekekela fucked around with this message at 02:21 on Jul 11, 2007 |
# ? Jul 11, 2007 02:03 |
|
I'm at home now, so I can't try it 'til the AM, but I'm hoping that SelectedValueChanged will be the winner. For those keeping score at home, I'm ideally looking for something that will fire when the list gets populated and when the user selects a new value without me explicitly calling a function.
|
# ? Jul 11, 2007 03:01 |
|
salithus posted:For those keeping score at home, I'm ideally looking for something that will fire when the list gets populated and when the user selects a new value without me explicitly calling a function. Like I suggested, you're probably going to be looking for a method to fire when the data context changes as well as the SelectedIndexChanged event. Try DataSourceChanged or BindingContextChanged.
|
# ? Jul 11, 2007 04:06 |
|
csammis posted:Like I suggested, you're probably going to be looking for a method to fire when the data context changes as well as the SelectedIndexChanged event. Try DataSourceChanged or BindingContextChanged. I guess I didn't word that very well. What I was looking for is something that would populate my ListBox whenever a new value was selected. I thought that giving it the ListBox a DataSourcewould leave the SelectedIndex at -1 and that by setting SelectedIndex to 0, I would be setting the default selection and firing an event for "hay, i've got something new" by using the SelectedIndexChanged event. It turns out I was incorrect and SelectedIndex was already 0, so setting it to 0 didn't change anything, and my ListBox wasn't being populated with the new initial value. Now, however, I'm using SelectedValueChanged and it's working like a charm (I needed it to handle both the data changing and the index changing, and it does). Thanks guys! I'm sure I'll have more questions later today.
|
# ? Jul 11, 2007 14:12 |
|
Two new questions: 1) Is there a better way to bind the enabled value of a combobox to the checked value of a check box besides: code:
|
# ? Jul 11, 2007 16:12 |
|
salithus posted:1) Is there a better way to bind the enabled value of a combobox to the checked value of a check box besides: quote:2) I've got three criteria: product, date, equipment. Each time one of these changes, then I need to update a DataGridView. Is it better to write a function and call it from each change event, or to specify each of the change events directly as the function?
|
# ? Jul 11, 2007 16:30 |
|
It is time for me to go balls deep into WPF (I've been putting it off for a while now). So I have a few questions: 1.) Visual Studio 2005 with the extensions for .NET 3.0 seems a bit glitchy when dealing with XAML. Everything compiles fine, but the editor is shakey. Will the Orcas beta be much better here? 2.) You that are trying Orcas: is it working pretty well side-by-side with VS2005? I assume it does, since traditionally all the Visual Studios have never given me any problems working side by side.
|
# ? Jul 11, 2007 17:37 |
|
SLOSifl posted:Nope, that's how you do it. It's not like there's any performance issues there, why isn't that good enough? I'm looking for elegance and making sure that I use the tools I have to get the job done instead of making new tools. No sense in rewriting everything that's already there. Also, I found a better way to do #2. I'm using an intermediate BindingSource and applying .Filter on it. Whee!
|
# ? Jul 11, 2007 17:50 |
|
Ethangar posted:1.) Visual Studio 2005 with the extensions for .NET 3.0 seems a bit glitchy when dealing with XAML. Everything compiles fine, but the editor is shakey. Will the Orcas beta be much better here? Ethangar posted:2.) You that are trying Orcas: is it working pretty well side-by-side with VS2005? I assume it does, since traditionally all the Visual Studios have never given me any problems working side by side. I'm not aware of anything in WPF requiring that you move to Orcas except for the slightly better editor. Of course you do get all the new things that come with 3.5. It's a little depressing I'm that excited about a native implementation of HashSet...
|
# ? Jul 11, 2007 17:55 |
|
Ah, fankey, you're becoming my go-to guy for WPF questions Thanks again.
|
# ? Jul 11, 2007 18:07 |
|
csammis posted:an additional stack frame every time the event handler is called for real Do you (or anyone else reading this) have any idea what the normal overhead is for a stack frame in .Net? This question intrests me greatly because our lead developer has chosen to use the MVP model for our UI development and it tends to result in a far larger number of method calls than we really need. I can't find anything good on Google, but I have a hard time finding anything out about general .Net stuff most of the time since there's so much chaff out there in the form of 'SomeBodyWhoThinksHesSooClever at someshittysite dot net' and also every website in the .net domain. Also, does anyone else wish google would mark RSS feeds or seperate them out of regular search results in some way?
|
# ? Jul 11, 2007 18:57 |
|
Munkeymon posted:Do you (or anyone else reading this) have any idea what the normal overhead is for a stack frame in .Net? This question intrests me greatly because our lead developer has chosen to use the MVP model for our UI development and it tends to result in a far larger number of method calls than we really need. Size-wise I don't think it's particularly huge - it's definitely relative to number of local variables, of course. A single call doesn't necessarily take a lot of time to jump either (but repeated calls do, that's why performance can improve with inlining)...but personally I just hate enormous call chains. I'm mad about stack traces I get that end with "56 more" (thanks Eclipse! ) quote:Also, does anyone else wish google would mark RSS feeds or seperate them out of regular search results in some way? That would be nice indeed.
|
# ? Jul 11, 2007 20:00 |
|
csammis posted:Size-wise I don't think it's particularly huge - it's definitely relative to number of local variables, of course. A single call doesn't necessarily take a lot of time to jump either (but repeated calls do, that's why performance can improve with inlining)...but personally I just hate enormous call chains. I'm mad about stack traces I get that end with "56 more" (thanks Eclipse! ) See, with MVP, you need ~3 calls to do any one thing on any one layer of your UI, so if you have something like a form holding tabs which hold forms wich hold controls, then talking to that grandchild control is a 12 step process (as opposed to 4). Even where it's something relatively simple like telling a browser to go back. This concerns me because I cant seem to help but worry about ostensibly stupid poo poo like the ammount of memory wasted by stack frame headers (not to mention that debugging things turns into a huge headache). These probably arent inlineable calls, either, since each of the three layers of each control lives in a seperate namespace with its own assembly and most of the calls are made to interface methods. Interfaces live in their own namespace, too.
|
# ? Jul 11, 2007 20:21 |
|
This is a really stupid question but it's one that no amount of googling or poking around has seemed to yield a result. Maybe I'm just doing something wrong. I have an XML file. In this file, let's say I have.. <boobs>d</boobs> <boobs>c</boobs> <boobs></boobs> I'd like to know if the node is empty or not when I read it with XmlTextReader. So when it hits the last boobs, I want to be able to do.. if (the node is empty) { do this } Nothing I've been able to find seems to tell me how to do that. .IsEmptyElement is for <boobs/>, which isn't what I'm working with. I thought maybe it was returning null, or String.Empty, or something but none of that seems to work. Anyone happen to know? Edit: This is in C# .net. casseopei fucked around with this message at 21:25 on Jul 11, 2007 |
# ? Jul 11, 2007 21:23 |
|
casseopei posted:I'd like to know if the node is empty or not when I read it with XmlTextReader. Try code:
|
# ? Jul 11, 2007 21:30 |
|
genki posted:It's not an elegant solution, but based on what you need, this might be the only way... Doesn't seem to work. It seems that Explorer wants to keep a permanent lock for some reason on the file, so it's constantly throwing exceptions. This is depressing . Regardless, thanks for the help so far guys, I appreciate it.
|
# ? Jul 11, 2007 21:30 |
|
csammis posted:Try Thank you very much for the information. It doesn't seem to be working, since the 'empty nodes' are still not activating the code inside when they should be. I can't do what you did exactly, however, because (I think) I can only do that with XmlDocument and so on instead of XmlTextReader, since InnerText isn't available for me to call. I used LocalName as a best guess for what the equivalent would be. Here's my actual code snippet - the idea is to add what's in <imagename> if there's something there, but if not to add what's in <text>: code:
casseopei fucked around with this message at 21:50 on Jul 11, 2007 |
# ? Jul 11, 2007 21:43 |
|
casseopei posted:I used LocalName as a best guess for what the equivalent would be. That's not what LocalName is...don't guess, use MSDN In fact, you already have your answer. ReadString() returns the contents, so if that returns a blank string, you've found your empty element. edit: You're also already using LocalName in the switch statement, so that wouldn't be returning a blank string at all
|
# ? Jul 11, 2007 21:50 |
|
csammis posted:That's not what LocalName is...don't guess, use MSDN In fact, you already have your answer. ReadString() returns the contents, so if that returns a blank string, you've found your empty element. I am insane. Ok, thanks a lot, it's working now! I was wrong with my syntax but was also wrong logically, and now it's all straightened out. casseopei fucked around with this message at 22:35 on Jul 11, 2007 |
# ? Jul 11, 2007 21:51 |
|
pliable posted:Doesn't seem to work. It seems that Explorer wants to keep a permanent lock for some reason on the file, so it's constantly throwing exceptions. The directory you're watching isn't on a network share by any chance is it? Windows has some weird hangups about files on network shares that could be causing that error. Try getting WhoLockMe to see if it's really locked or if the error is innaccurate. Edit: You should still try seeing what's locking it, if anything, to see if the error is correct. I know I get some weird messages back on Vista from programs that aren't aware they can't write to places for security reasons and I have seen weird erros on XP cause by 3rd party software. Better to be sure at any rate. Munkeymon fucked around with this message at 22:56 on Jul 11, 2007 |
# ? Jul 11, 2007 22:06 |
|
Munkeymon posted:The directory you're watching isn't on a network share by any chance is it? Windows has some weird hangups about files on network shares that could be causing that error. Try getting WhoLockMe to see if it's really locked or if the error is innaccurate. Nah, I'm running and testing this on my local PC.
|
# ? Jul 11, 2007 22:17 |
|
In asp.net 1.1, what's the best way to retain form values while going to another page on the server, to restore when the user navigates (not with the browser back button) back? It seemed like saving the page's viewstate might be an option, but after reading around a little bit, this seems like something it was not intended for. I was even reading viewstate does not hold form values. Is this true? Basically I'm just trying to make a "wizard" style data entry application that lets the user go forwards and backwards. I could probably rig something like manually loops through a page's controls and saving them to the session, but that seems ugly.
|
# ? Jul 12, 2007 05:43 |
|
After all that work to get the DataGridView working, I realized that putting the connection et al into the MdiChild was stupid, since the results from the SQL query are static while the user has the application open, no matter how many documents they use. So, what's the best practice for moving this to the MdiParent? I think that I need to move the DataSet to the MdiParent and give each MdiChild its own BindingSource that's bound to DataSet. Since MdiChild isn't inherited from MdiParent, I can't use protected. Is setting up the DataSet as an internal what I'm looking for, or is there a better way? salithus fucked around with this message at 14:49 on Jul 12, 2007 |
# ? Jul 12, 2007 14:45 |
|
Sabotaged posted:In asp.net 1.1, what's the best way to retain form values while going to another page on the server, to restore when the user navigates (not with the browser back button) back? It seemed like saving the page's viewstate might be an option, but after reading around a little bit, this seems like something it was not intended for. I was even reading viewstate does not hold form values. Is this true? The easiest way is to simulate the ASP.NET 2.0 wizard controls never have them leave the page. Just show and hide panels as needed. PROTIP: encapsulate panels in user controls so you don't get insane amounts of code on one page. PROTIP2: use viewstate-backed properties to save internal state on the page for things like page number and such. I wrote a lot of those type things back in the 1.1 days . . .
|
# ? Jul 12, 2007 14:57 |
|
Sabotaged posted:In asp.net 1.1, what's the best way to retain form values while going to another page on the server, to restore when the user navigates (not with the browser back button) back? It seemed like saving the page's viewstate might be an option, but after reading around a little bit, this seems like something it was not intended for. I was even reading viewstate does not hold form values. Is this true? While I'm not sure it's the best way, session variables do exactly that. http://msdn2.microsoft.com/en-us/library/87069683.aspx
|
# ? Jul 12, 2007 15:00 |
|
Richard Noggin posted:While I'm not sure it's the best way, session variables do exactly that. http://msdn2.microsoft.com/en-us/library/87069683.aspx In 1.1, thats what session variables are used for alot. The idea of keeping it all on the same page and show/hide panels works fine but the viewstate will be much larger and debugging is more painful. So it is a give and take.
|
# ? Jul 12, 2007 15:44 |
|
Is there a way of finding the client area of a window as a rectangle, relative to the entire desktop (using the window's handle)? I've found two API functions which almost do this, but neither do quite what I want:
Edit: I found a slightly hacky way of doing it: you just calculate the width of the borders from the rectangles received from each of these functions (by subtracting the width of the client area from the width of the window and dividing by 2) and you can then find where the client area lies within the window: code:
Inquisitus fucked around with this message at 20:16 on Jul 12, 2007 |
# ? Jul 12, 2007 19:53 |
|
What's a good way to check to see if an assembly exists in the GAC? I have a couple small apps that get used in our office, that rely on a third-party assembly. Basically, I just need to do a check, then pop up a message "HAY GUYZ, YOU FORGOT TO INSTALL <REQUIRED COMPONENT>" if it's not there. Note that this is only required for a part of the program that gets used rarely; so, I don't necessarily want to prevent them from running the program if it's not there. Likewise, using Assembly.Load() every time the program starts didn't seem great either.
|
# ? Jul 12, 2007 20:08 |
|
MrBishop posted:What's a good way to check to see if an assembly exists in the GAC? I have a couple small apps that get used in our office, that rely on a third-party assembly. Basically, I just need to do a check, then pop up a message "HAY GUYZ, YOU FORGOT TO INSTALL <REQUIRED COMPONENT>" if it's not there. If it's rarely used, I'd think that it'd be better to check it when it's actually needed. According to this you should be able to run "gacutil.exe /l <assemblyName>" and parse it. I dunno about that though.
|
# ? Jul 12, 2007 20:15 |
|
Inquisitus posted:Is there a way of finding the client area of a window as a rectangle, relative to the entire desktop (using the window's handle)? The API way: code:
|
# ? Jul 12, 2007 20:44 |
|
MrBishop posted:What's a good way to check to see if an assembly exists in the GAC? I have a couple small apps that get used in our office, that rely on a third-party assembly. Basically, I just need to do a check, then pop up a message "HAY GUYZ, YOU FORGOT TO INSTALL <REQUIRED COMPONENT>" if it's not there. I think Assembly.Load is fine because if that part of your app uses the assembly, it's going to get loaded anyway. It's probably best to defer the call until they try to access that part of the app. You could see whether or not the assembly was loaded (so the check only happens the first time) and then try to load it if it isn't.
|
# ? Jul 12, 2007 20:48 |
|
ljw1004 posted:The API way: Much better than my way Inquisitus fucked around with this message at 21:02 on Jul 12, 2007 |
# ? Jul 12, 2007 20:49 |
|
|
# ? Jun 2, 2024 14:10 |
|
Fastbreak posted:In 1.1, thats what session variables are used for alot. The idea of keeping it all on the same page and show/hide panels works fine but the viewstate will be much larger and debugging is more painful. So it is a give and take. I have done this both ways and unless you are severely bandwidth constrained, inpage controls are the way to go. Main issue is that bad things can happen to sessions with little or no warning, causing interesting issues. Or making you do a whole lot of defensive programming. Whereas with a series of panels one can be reasonably assured that things are lying about in ViewState. As for keeping the codebase managable, that is what user controls are for. Use them like webparts to pass bits of business information back and forth. They are your friends.
|
# ? Jul 12, 2007 21:19 |