I have a form which includes AdobeShockwave player for play some YouTube videos by clicking on the different buttons.
I've set a comboBox (This allow user to choose what events need to show it in the AdobeShockwave) and 3 Radio buttons (for see the rest of the buttons and videos).
I've already put codes in the Visual Studio and compiled and it was true.
But i have a problem.
Just imagine i put some codes which includes : when user choose number one in the combobox (index 1) and then choose the radio button, Set the Text of Buttons.
But now i wanna do something and put some codes which includes, When user choose button 1 , specific video show in the Shockwave and when user click on the button 2, Show the specific video and ... .
I know i have to put this code in the Button event :
if (comboBox1.SelectedIndex == 1)
axShockwaveFlash.Movie = "Video's URL";
But i code above happen if :
1. ComboBox1.SelectedIndex == 1
2. RadioButton1.Checked = true
3.Then when user click in the button 1 Show the video.
I put my image which can help you.
Thanks in advance for your Help.
And these are my codes :
private void radioPage1_CheckedChanged(object sender, EventArgs e)
{
if (comboBox1.SelectedIndex == 1)
{
/* Show/Display the numbers of row in the form*/
lbl1.Show();
btn1.Show();
/* Change the label of the Events*/
lblEvents.Text = "StarCraft II ProLeague 2016 S1 :";
}
Update
There is no one to answer my problem ?
Related
When I Click specific cell in DataGridView in my Winform project, let say ColumnIndex 5 , then I want to popup or open a litle form (not MessageBox) in the same position as Clicked Cell. Right now When I click specific cell, then my form opens in center of Screen. But I wont to open iy in the same position or Location of that Clicked Cell. I don't know how, but I think I need to get location or position of Clicked cell and by some how integrate to popup form.
This is my code and Test form opens in the middle of screen when I click ColmnIndex 5
private void dgvComputersAdgv_CellMouseClick(object sender, DataGridViewCellMouseEventArgs e)
{
if (e.ColumnIndex == 5)
{
Test ts = new Test();
ts.ShowDialog();
}
}
Thank you in advance !
It appears it could be the forms StartPosition property setting.
The default choices appear to be Manual, CenterScreen, WindowsDefaultLocation, WindowsDefaultBounds, and CenterParent. Click the in an empty area of the form you want to adjust the StartPosition in Design view. Try out CenterParent or Manual to see if that gets you closer. Otherwise, you will need to update the FormName.Designer.cs - this.StartPosition = System.Windows.Forms.FormStartPosition.CenterScreen to this.Position = System.Windows.Forms.FormStartPosition.custom variable that holds the location........
I made a Tic Tac Toe game and I'm trying to add a few features.
I was used to handle the taken buttons with
button.enabled=false;
The problems is that the text on the buttons turns grey.
So I made a button click for each button:
A1_Click, A2_Click, and so on
This is my code into A1_click, and it's the same for the other buttons, the only thing that changes is "A1", "A2", and so on
Button b = (Button)sender;
if (!A1.Text.Equals(""))
{
MessageBox.Show("Not A Valid Input");
}
I get "not a valid input" when I click a button I've already clicked before, I'd just like to be able to click an another button.
I don't want to lose my turn if I click on an already taken button
Based on what I have read I think I know what you are looking for. You are looking for a way to force the user to lose a turn when they click a button that has already been taken, and you do not want to set the enabled property to false. If that is what you want, then I might have some code that could help. First if you are assigning the same click event to multiple buttons with different functions you should try something like this:
for (int i = 1; i < 10; i++)
{
string currentButtonName = "A" + i;
Control currentButton = this.Controls.Find(currentButtonName, true).FirstOrDefault();
currentButton.Click += OnGameButton_Click;
}
What this is doing is searching your form for a control that has a specified name, and since your buttons have a similar name we can easily search for them. Then we can bind a specific function to all of them so that instead of 9 functions to modify you only have 1, and you can validate that they all work the same. Here is the OnGameButton_Click() event code:
private void OnGameButton_Click(object sender, EventArgs e)
{
if (!hasGameStarted || shouldLoseTurn)
return;
// This is the current button user pressed
Button b = (sender as Button);
if (b.Name.Contains('A') && b.Enabled)
{
if (!b.Text.Equals(""))
{
MessageBox.Show("Not A Valid Input! You have lost your turn.");
shouldLoseTurn = true;
}
else
{
b.Text = currentPlayersLetter;
shouldLoseTurn = false;
}
}
}
As you can see with some flags we can monitor the game, and force the buttons to react accordingly take a look at the beginning of the function. We have to validate that the game is engaged, and that the current user has not lost their turn due to pressing the same button. From there we just need modify what you had so that if they do press the same button twice then we modify the shouldLoseTurn flag as needed.
The other approach is to just simply use the Button.Enabled property to disable the button from use. I know you do not what the button to be grayed out, but if you create your own style guide for the button you could make it how you want. This can be challenging though because you will have to modify the default style template for the button to achieve this. Here is another question that discusses just that here
I have one table into database named card_details which has two fields card_number, card_value. I want to create some asp.net application where user enter the value of card number in textbox and automatically fetch the respected card value into another textbox.
Suppose user has more than one card then we have to give one button (Add More Card). After clicking this button its automatically generate two textboxes on runtime as mentioned my requirement where user can put the card number and its finds the value in another textboxes. And its also sum the card values(Gross Total) and show into another textbox.
$('#idTextbox').val('type texh whatever you want');
idTextbox: id of the dynamic textbox.
Is this, what you want to know.
Add a Panel to your page and then in the code behind of your Button use this to add controls dynamically:
TextBox dynamicTxtBox = new TextBox();
dynamicTxtBox.Text = "(enter text)";
dynamicTxtBox.ID = "dTxtBox";
Button dynamicBtn = new Button();
dynamicBtn.Click += new System.EventHandler(dynamicBtn_Click);
Panel1.Controls.Add(dynamicTxtBox);
Panel1.Controls.Add(dynamicBtn);
private void dynamicBtn_Click(Object sender, System.EventArgs e)
{
//your code here
}
Similarly you can add another TextBox as your requirement is two boxes.
Right I have got a list box which contains a list of tracks and when the track is pressed it moves to a second list box, what I now need to happen is have the first item that's in the second list box move automatic to a text box.
This is my current code for the first move
private void genreListBox_DoubleClick(object sender, EventArgs e)
{
playlistListBox.Items.Add(genreListBox.SelectedItem);
}
I am thinking it should be something like this
presentlyPlayingTextBox.AppendText(playlistListBox.);
But I'm not sure how to add the first line without clicking it.
I have tried this but I get an error for the value.
presentlyPlayingTextBox.Text = playlistListBox.SelectedItem.Value;
Normally you would use something like the 'SelectedIndexChanged' or 'SelectedValueChanged' action of a listbox, otherwise events like DoubleClick will fail if the keyboard is used to change the selection.
Also that event should be triggered on the second listbox when it is changed by the first.
EDIT:
On a standard Listbox, there is no .SelectedItem.Value, only .SelectedItem.
However as a listbox holds objects, not just text, you need to say you want the text value.
presentlyPlayingTextBox.Text = playlistListBox.SelectedItem.ToString();
I don't know if I fully understand your question, but if you're just attempting to move the first item from ListBox_2 to a textbox, would the following work?
presentlyPlayingTextBox.Text = playlistListBox.Items[0]?.Value; // C# >= 6
presentlyPLayingTextBox.Text = ((playlistListBox.Items == null) ? playlistListBox.Items[0].Value : "" ); // C# < 6
You could also create your own delegate/event that would fire when the user did some action.
i've two groups of radio buttons, a drop down list & a submit button..on corresponding selected radio buttons & drop down item i need to open next specific form..
say if i selected in first radio button say Existing user(of website) and in another say individual, and in drop down if i select residential property then it should open a residential form,if i select commercial property then it should open a commercial form etc.
can u please help me out??
I assume there is button and on click of this button you have open either of the forms.. You can add a Button_Click() event handler and in there check
Psuedo-code looks like this
if(radioButton1.selected && dropdownList.SelectedValue =="Residential")
{
frmResidential frmRes = new frmResidential();
frmRes.Show();
}
Code example in previous post will work for window forms. Looks like you have Web Application. In this case you can use Response.Redirect method to go to different web form.
if(radioButton1.selected && dropdownList.SelectedValue =="Residential")
{
Response.Redirect("YouPage.aspx");
}