I have a Data Repeater in a Windows Form, within the data repeater I have a label and either a radio button or combo box, the amount of radio buttons and the text for them is brought in from my database as is the label and combo box.
The label is a question and the radio buttons or combo box allows the user to answer the question.
What I want to do is get the checked status of the radio buttons so I can then reveal the next question if it is needed. e.g. only show question 2 if question 1 is answered No.
'0 = Index in Repeater.
Dim bolChecked As Boolean = CType(rptYourRepeater.Items(0).FindControl("IdOfRadioButton"), RadioButton).Checked
Related
How would you change the Form size depending on the width/length of a Label?
I need to resize a Form depending on how much text there is in a Label (the text is automatically generated from case statements).
You can try to put the AutoSize to True of the Form
Open the Form and put a Label on it , the Label gets a Name lets say Label1.
Rightclick on the Form and open Properties
Then Choose AutoSize to True
Then return to the Form and dubbleclick on the Form this case Form1, Form1.vb is open.
In Form1_Loadif it is another Label you have to adjust it to the right Name:
Label1.Text = "This is a example text and a bit longer zo the form is getting bigger"
Run it and there it is :
Look here https://learn.microsoft.com/en-us/dotnet/api/system.windows.forms.form.autosize?view=windowsdesktop-6.0
I have a gallery and a radio button.
In the gallery where the user has to answer questions.
Each question can be a radio button with multiple choice answers, for example one could be a yes no response another could be a yes no unknown choice.
These choices are determined from the list field called answerchoice .
In the answerchoice field it might be populated with
yes\no or yes\no\unknown or 1\2\3\4.
Therefore in the items of the radio button I need to pass the values of the answerchoice field
Thank you
If the separator for the options is the \ character, then you can use the Split function to convert that into a collection that you can set to the Items property of the radio button control:
Split(ThisItem.Value, "\")
hi i have a combo box in a form which has the following values.cash sales,refund,debtor sales,debtor refund. i have added these values in the items collection.Following is the issue,the combo box during form load does not show the first value which is cash sales and which should be the default value displayed on form load.but its not showing.
I have even set the combo box style to drop down list but still its not showing.
![the combo box in form which has the mentioned issue][1]
Use this to show the default value by index:
ComboBox1.SelectedIndex = 0
Update:
Or if you cant determine the index in design time, you can use:
ComboBox1.SelectedIndex = ComboBox1.Items.IndexOf("defaultValue")
I want to make custom combo box which have contain datagrid and textbox too.
On clicks into combo box datagridview should be appear and selecting any row particular cell value of the datagridview added on the combo.
thanks in advance..
As your question is written I have no idea how to answer it, I can't figure out how you could sensibly show a DataGridView inside a ComboBox. I'm writing this answer with the assumption that you mean that the form should have a ComboBox that are "linked" to a DataGridView rather than actually contain it.
If so, all you need to do is to add the ComboBox and DataGridView to the form, make the DataGridView invisible. Then you handle the SelectedIndexChanged event for the ComboBox, in the handler, make the grid visibile, find the index of the row and column you want to show and write code like (code not tested so might not be correct):
grid.SelectedRows.Clear()
grid.FirstDisplayedScrollingRowIndex = rowIndex
grid.Rows(rowIndex).Cells(colIndex).Selected = True
grid.Show()
I'm writing a standalone application in VB.NET using Visual Studio 2005.
I want to display/hide a bunch of Buttons based on the selected value of a ComboBox. Each selection would have a different set of Buttons to display, and I'd like to have them arranged in a nice grid.
Driving a TabControl with the ComboBox value would be the kind of behavior I want, but I don't want it to look like a TabControl to the user because it might be confusing.
Is there a way to do this?
Basically, I'd like Selection1 of the ComboBox to show Buttons 1-4, Selection2 to show Buttons 5-11, Selection3 to show (maybe) Buttons 1, 3, 5, 6, and 8, etc., have them arranged nicely, and have the GUI show only the ComboBox and the buttons.
Thanks in advance as always!
Use a Panel control (or multiple if the items aren't grouped right next to each other) and set the visibility accordingly.
(Added)
You CAN stack panels on top of each other, so that the buttons all look like they're in the same location. but it becomes a maintenance nightmare and I don't recommend it.,
Hack warning - the following is a hack, but it works.
Another option is to use a tab control, but hide the tab buttons. (You can do this by positioning a panel over the buttons, but you have to be careful of letting the user resize the form.) Then you set the TabIndex based on the drop-down changing.
Edit again - added per comment
If you use the hack, you can add this into the ComboBox's selected index changed event....
(code may be wrong, as I'm not at my dev pc and can't check, but you get the idea)
TabControl1.SelectedIndex = ComboBox1.SelectedIndex
You could put all of your buttons on a panel on your form. Then when the SelectedIndex event of the combobox fires, you can loop through the buttons on the panel and turn them on and off based on their Tag property.
For this example you would set the Tag property of each button equal to the combobox index or indexes that you want it to turn on for. If you want it visible for more than one combo selection just comma seperate the index values in the tag property.
You don't have to key off of the combobox index. You could use the selected text for example. If you did that, just put the texts to show the button for in the tag property and change the code from ComboBox1.SelectedIndex.ToString to ComboBox1.SelectedText.
The buttons will turn on and off where they are placed at design time, but you could add some code here to arrange them dynamically as well so that all the visible buttons are neatly arranged.
Private Sub ComboBox1_SelectedIndexChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ComboBox1.SelectedIndexChanged
For Each ctrl As Control In Me.Panel1.Controls
If TypeOf ctrl Is Button Then
If Array.IndexOf(Split(ctrl.Tag, ","), ComboBox1.SelectedIndex.ToString) > -1 Then
ctrl.Visible = True
Else
ctrl.Visible = False
End If
End If
Next
End Sub
Maybe using a FlowLayoutPanel will help you display the buttons.
You can use a jagged array to define which buttons belong to which combo-box item.