I need some input on a class that has been bothered me all day. What I want to achieve is listing buttons next to eachother and show them max 8 at the time. So if there is more then 8 buttons I'll use navigation buttons to scroll through the possible buttons.
The problem I have is, since these are generated in a loop - the click events doesn't behave like I want.
This is the class I've made for this:
Buttonmanagement class
The problem is probably very easy but I've stared on this way too long! When I first trigger the method drawGroupButtons() I found it easiest too see the problem when you show the buttons in the middle. I can with no problem go in one direction, but as soon as I change direction the problems start to appear.
In my example (in another not attached class) I've used 128 buttons and start generating them from 43 to 57. If I go left in the "menu" I get:
29,43 ->
15,29 ->
0,15
THe above values is the content of p_Start and p_End. This is just how I want it. If you noticed it's different amount of buttons in each step, it is because of the navigation buttons (the first group 0,15 only have a right-button). But when I start going right, the initial values are used (in this case 43,57). So I will jump from 0,15 to 57,71 which is terribly wrong :( It's like the click events doesn't know the changes the other one does. Do anyone know what I'm doing wrong here?
The problem is finally solved!!!
The error was that navigationbuttons were lying on top of eachother so the solution were actually working but the wrong button was clicked. In case someone want to use this, the only change I did was to move the declaration of the bPrev and bNext variables to the top of drawGroupButtons() and then added Constrols.Remove(bNext) under bPrev scope, and Controls.Remove(bPrev) under bNext scope!
Related
I have a wpf grid setup where I have two custom buttons that are next to each other. First picture is how the design window looks like, however, functionally, it looks like the second picture. I want them to function like the grid doesn't block them (closely resembling the first picture.)
The current xml I have is based on this MSDM which is very basic.
I do not know how to proceed. Do I have to use a different control panel/container or is there a setting to allowed them to extend passed the grid if the other button isn't above it (like zpanel?)
E: I couldn't find any other questions for this, so please link to any searches/posts with information on it.
Turns out I can use canvas and just do a bit more xml to keep the design the same. I would still like to know if it is possible to overlap them in any way for future use.
As the title suggests, I am having some issues when trying to programmatically check a radio button in a Windows 8 Store App. So I realize on a WinForms .NET application I would do something like:
rad.Checked = true;
In WinRT, I am trying this:
control.RadYes.IsChecked = true;
This is what I would assume would cause the Radio Button to be pressed; however, in the UI, it still shows nothing is checked. If I place a breakpoint, I can hover over RadYes, and it shows the property = true. Is this not the correct way to do this?
The idea, is I am allowing a user to pick back up where they left on when filling out a form. So it retrieves the values from the database and correctly getting into my switch/case to set the value--but the UI doesn't change.
Another thing I noticed that I am also about to try--is that I didn't assign a Group to my 3 Radio Buttons. Can someone clue me in as to what I might be doing wrong? Thanks!
OK, so my solution was to add GroupName="YesNoNA" in the XAML controls. I didn't change anything else, and now it works. I searched for an hour trying to find information about this, so hopefully this will help someone else out.
I got an application that the main form contains a System.Windows.Forms.ToolBar.
I want to add a new System.Windows.Forms.ToolBarButton with a little longer text from the rest. so on the designer window when I press Enter after I changed the text, I see part of it with 3 dots (...) and when I click OK, the toolbar itself gets very wide for some reason and the spaced between every item gets bigger.
I couldn't find a lot online about this control... maybe it's old but I can't change it.
I tried to access the buttons but when I drag, the whole toolar mooves.
What can I do ?
Thank you very much !!
I have a set of sixteen radio buttons. When i press a radio button, i want two buttons to appear (on/off). and when i press any button, a function executes(i have no problem with this),;
when i go to the next random radio button and press it, the same thing should happen., but when i go back to the previous radio button that i pressed, it should still show the action that was carried out(i.e either on/off). It should retain the action carried out on it forever, until manually changed.\
all i need is the demonstration of the above in code for at least 3 buttons, and i will figure out the rest myself....
thanks
Use a trigger in the XAML, it is fairly simple..
http://msdn.microsoft.com/en-us/library/system.windows.datatrigger.aspx
So basically you would use the checkbox value of the original to either show or hide (the property in the style to modify) the others.
If XAML is not your cup of tea and you wish to use codebehind (really personal choice) this may help you.. I am not a WPF/MVVM stickler by any means (some duct tape helps now and then) but putting all sorts of events like this in the codebehind can get messy..
http://www.codeproject.com/Articles/28959/Introduction-to-Attached-Behaviors-in-WPF
This should be a relatively simple javascript item you need to do. Ensuring that you have ids for each of the items then make all the changes on the page and then on the final postback you will have all the correct values
I am making a game based on Game State Managment pattern. I made 20 button on a 2nd page that let the user pick the level.
LevelButton : TexturedDrawableGameComponent
Inside LoadContent() buttons are created and added to GameComponent collection. If I get this right the GameCompoenent is a sort of global collection, so when the user goes back from 4th page to 2nd app will add another 20 buttons.
I added a loop that clears all LevelButtons from the collection, but seems this is wrong.
Is it DrawableGameComponent the wrong tool for creating buttons?
Yes.
DrawableGameComponent and its friends are optional bits of the XNA framework. Consider them helpers. Simple example implementations.
If you need more or different functionality to what they provide, you must replace them with your own implementation!
In this case it seems that what you want is a "Button" object (like your LevelButton), probably with methods like Update and Draw.
And then you want some kind of "Button Container" object that will hold all these buttons, and keep them drawn and updated when they are on-screen. But not do anything with them while they are off-screen.
(You could create your own instance of GameComponentCollection to manage this, and keep using game components. But you still have to provide your own draw/update/load/unload/initialise logic. The logic for Game.Components is internal to Game and not reusable. I recommend just using a List - keep it simple!)
The alternative to creating multiple collections - which is to add and remove (or disable/enable) components from the global collection - is horrifically ugly and error-prone. Don't do it.
I think that it is not wrong if it runs.
Maybe you can approach this in several more elegant ways or improving the way you do it... but the matter is that it have to run.
Maybe you are trying to remove the button when you click it, this will give you problems because that button is being updated.
When the level selection screen becomes inactive or destroyed is the time to remove the buttons.
Of course, you can create a button collection class, that manages the list of buttons, and then you only have enable/disable or remove one DrawableGameComponent, and can be useful in other screens.