|
Run through your code and ensure that the combobox is not reassigned datasource / values.
The combo will refresh in this case.
To avoid this, you can actually store the present value locally and then reassign to combo once save action completes.
|
|
|
|
|
I am running from source code, while I am calling this command "this.BindingContext[data[1, 0]].EndCurrentEdit();" it is resitting to the original value.
|
|
|
|
|
I have a win form application in which i have to move a picture box with arrow keys.
The problem is that when other controls like text boxes are added in the form at run time and then picture box losses its focus on pressing arrow key and picture box does not move.
please help me..
|
|
|
|
|
Firstly if this is VB I would put in the VB Forum[^].
Secondly you haven't shown any code snippets etc.
My first thought is that if you are using code to draw your controls rather than drag and drop from the designer can't you change the order that they are drawn?
Every day, thousands of innocent plants are killed by vegetarians.
Help end the violence EAT BACON
|
|
|
|
|
IIRC, a PictureBox cannot have focus while in the same container with a TextBox regardless of the order of instantiation. I think it's because usually there is no need to interact with a PictureBox. It just exists to display a picture.
Ciao,
luker
|
|
|
|
|
Thanks have learnt something new today.
Every day, thousands of innocent plants are killed by vegetarians.
Help end the violence EAT BACON
|
|
|
|
|
I don't know your control stack. But Form[^] has a boolean KeyPreview[^] property. Set it to true and handle the cursor keys outside of the picturebox. Or catch it outside and redirect it where you need it.
Ciao,
luker
|
|
|
|
|
focus picture box when entering form[^]
As Lukeer has stated the picturebox can not have focus as it is only designed to display a picture rather than accept keyboard presses.
Every day, thousands of innocent plants are killed by vegetarians.
Help end the violence EAT BACON
|
|
|
|
|
Hi guys,
I created a 3x3 puzzle game and I randomize the button at form load.
It's a success, but sometimes I can't solve the puzzle no matter how hard I try.
This is where the puzzle stuck at,
http://i39.tinypic.com/9k17dh.jpg[^]
Maybe there is a way to random puzzle?
Or maybe I don't know how to play puzzle?
|
|
|
|
|
Usually it's called "8-puzzle" (special case of N-puzzle), and exactly half of them are unsolvable.
You can check whether it's solvable[^] and then generate a new one if it isn't.
|
|
|
|
|
There are a couple of ways to randomise it:
1) Insert each piece of the puzzle at a random location on the board, by using the random number generator to specify the location. This is quick to generate, but as Harold says, it can generate puzzles that can't be solved - you need a post-processing step to ensure that it can.
2) Use the random number generator to generate a direction, and move the pieces that way, exactly as if the user had done so. You then repeat this a number of times to "scramble" the puzzle. This is slower to generate, but the result is always solvable, and it means that a "difficulty level" can be added very simply by changing the number of times the random move is implemented.
The universe is composed of electrons, neutrons, protons and......morons. (ThePhantomUpvoter)
|
|
|
|
|
I thought about that second method, but concluded that I couldn't guarantee anything about how random the result would be, so I decided against recommending it.
It could be faster though, the way I mentioned has a probability of 0.5 at every step to terminate, you could have bad luck.
|
|
|
|
|
It generally works out pretty random: since at any stage you will have 4, 3, or two possible moves (depending on where the hole is in respect of the edges) it's a pretty simple matter to "ban" the move which reverses the previous one. That does give good randomness in practice - it's down to how many iterations you go for.
The universe is composed of electrons, neutrons, protons and......morons. (ThePhantomUpvoter)
|
|
|
|
|
I suppose so, but I had to think of that argument for why the "swap any two random elements n times" algorithm doesn't shuffle an array correctly - some configurations have more paths to them than others, so they get chosen too often.
I'm not sure that isn't the case here.
|
|
|
|
|
I was able to solve it using a timer that randomly click the movable button in 5 second and it worked.
Thank you very much for the help guys.
|
|
|
|
|
I have the following questions in regards to to placing a 'gui' interface on the top of a C# 2008 application so users can enter data.
1. I would like to know if it would be better to add a desktop form for an asp.net web forms page to the application? I would like to know what is better and why.
2. In addition, the two project files that are windows form apps currently, I would Like to know if I should make those web form projects, leave the project types alone, and/or what do you recommend? Based on your recommendation can, you tell me or point me to a reference I can use to make the coding change?
The following is a description of the application:
1. This program was originally setup as a console application, but I changed the application so that it would compile and run as a windows form application. I made the changed since I wanted to save all the output messages that were originally written to Dos popup windows to saved to log files for research and deubgging purposes.
2. This application has 4 project files. Two of the project files are class libraries and two of the project files are window form applications that I converted from a console project files to window form proejct files.
3.One of the windows form project files is the 'driver' of the application. I would like to add a 'gui' interface to the application so the user can enter data that can be utilized by the 'driver' project file.
|
|
|
|
|
classy_dog wrote: 1. I would like to know if it would be better to add a desktop form for an
asp.net web forms page to the application? I would like to know what is better
and why.
Impossible to answer seeing as we know nothing of what the app does, how it maintains its state, and how the user interacts with it.
classy_dog wrote: 2. In addition, the two project files that are windows form apps currently, I
would Like to know if I should make those web form projects, leave the project
types alone, and/or what do you recommend? Based on your recommendation can, you
tell me or point me to a reference I can use to make the coding change?
Again, impossible to say. See answer 1.
classy_dog wrote: 1. This program was originally setup as a console application, but I changed the
application so that it would compile and run as a windows form application. I
made the changed since I wanted to save all the output messages that were
originally written to Dos popup windows to saved to log files for research and
deubgging purposes.
You didn't need to change this to a Windows Forms app. All you had to do was write the messages going to the Console to a file. A simple method in your code would have done this very easily.
classy_dog wrote: 3.One of the windows form project files is the 'driver' of the application. I
would like to add a 'gui' interface to the application so the user can enter
data that can be utilized by the 'driver' project file.
Again, impossible to answer.
|
|
|
|
|
|
In a C# desktop application, I am using linq to sql to connect to a sql server 2008 r2 database. The applicatiion is setup to point to various databases depending upon the value in the app.config file.
The problem is code in the *.designer.cs gets overrriden somehow by 'defaults' in the .net problem framework. When this happens the 'using system.configuration' gets removed from the application and the 'default settings' values are used to get the database connection string values.
When I notice this problem occurs, I need to do the following: 1. place the 'using system.configuration' code back into *.designer.cs file, 2. change the code so the database connection info is obtained from the app.config file, 3. remove the property settings so the 'default' database connections are not used.
Thus can you tell me what is causing this problem to occur and how to
solve the problem?
|
|
|
|
|
You cannot modify the designer files at all. Any code you put in there WILL be overwritten and destroyed.
The stuff your'e talking about always goes into your Form.cs files, not the designer files.
|
|
|
|
|
So what you are saying if I place the code in form.cs, then the db connection string values will not be overriden? If so, can you show me some code I can use as a reference?
|
|
|
|
|
Serisouly?? If you need this kind of help, you REALLY need to pickup a beginners book on C# and work through it.
It's no different than if you were putting the same code in the designer file.
|
|
|
|
|
I have the following questions in regards to converting a C# 2008 appliation that is currently executed as a dll and now I want to change the program so that is executed as an api. I have the following comments to make which are:
1. This program was originally setup as a console application, but I changed the application so that it would compile and run as a windows form application. I made the changed since I wanted to save all the output messages that were originally written to Dos popup windows to saved to log files for research and deubgging purposes.
2. This application has 4 project files. Two of the project files are class libraries and two of the project files are window form applications that I converted from a console project files to window form proejct files.
3.One of the windows form project files is the 'driver' of the application. I would like to add a 'gui' interface to the application so the user can enter data that can be utilized by the 'driver' project file.
I have the following questions I would like to ask which include the following:
1. From what I described above, would you tell me what I need to do to convert the application I listed above from being executed as a dll and execute it as api? Is there any special considerations I need to take into consideration? Can you show me code and/or point be to a reference I can utilize to accomplish my goal?
2. Would it be better to make the 'gui' interface where the user enters data a desktop or asp.net web forms application? Can you tell me why one method would be better than another method would be?
|
|
|
|
|
not sure I understand you fully, but, I would move/'refactor' all the non gui/console code functions etc into a dll, and export their function calls etc - this is effectively your 'api'
The dll can then be used in a console or gui program
Im not sure your point in #1 is a good enough reason to change to a windows forms app - If it were logging/catpturing output messages, you could have used log4net for example .. even if you said you wanted to capture them to a DOS type window, that can be done from log4net
[edit]
btw - your second point #2 ..'depends' if only one user is going to be entering data and/or never from a 'remote' desktop, then maybe I'd prefer 'Forms' based - if multiple people may be entering data and you may move the solution to a more 'distributed' space, then, maybe asp.net web forms is the go ..
again, it all comes down to requirements/analysis - seperating the 'work functions' from the 'gui' type functions will help you whatever the case
[/edit]
'g'
modified 26-May-13 19:17pm.
|
|
|
|
|
classy_dog wrote: currently executed as a dll and now I want to change the program so that is executed as an api. An API is merely a set of classes/methods in a DLL.
1. You could just log the messages to a file (see log4net Tutorial[^]), rather than using popups.
3. If it is already a Windows forms application then you already have the GUI. Just add the controls to accept input from the user.
B1. You don't need to do anything, the API is in the DLL.
B2. Depends whether you have users that need to access it across the internet, if not then Windows.Forms is fine.
Use the best guess
|
|
|
|