rad menu , check if item text exists - vb.net

Using telerik and the radmenu, do you know how to check if the item exists by text
my menu contains the text "menu1"
If I use menu.FindItemByText("menu1").Enabled = False this will disable the button
BUT
If I use menu.FindItemByText("menuTEST").Enabled = False then I get an exception as this button does not exist.
How do I stop the error?
I tried this below but it say it cant return booloen
If menu.FindItemByText("menuTEST") then
'do this
End If

Try this:
If Not(menu.FindItemByText("menuTEST") Is Nothing) then
'do this
End If

Related

How to display an error message if dropdown list is null

I have a dropdown that displays nothing. If I hit the save button and nothing is displayed I want an error message stating something has to be selected
I've tried if ddl.POApprover.text = "" then display the message but that doesn't display
If ddlPOApprover.Text = "" And (Session("UserGroup") = 13) Then
MsgBox("Error: An Approver must be provided before you can save")
blnValidation = False
End If
I want the error to come up when I hit save but it doesn't
It's If ddlPOApprover.SelectedValue not .Text
A Combobox has an array from 0 to numberOfItems -1.
whenever there is nothing selected, it's index is -1
so you can check if ddlPOApprover.selectedindex < 0 then no item has been chosen
Edit: i also want you to try replacing And with AndAlso like:
If ddlPOApprover.Text = "" AndAlso (Session("UserGroup") = 13) Then
would it still give you an error? if not then you can choose either my main answer or leave it and just change And to AndAlso

Making a form that users enter a value into text boxes a certain number of times

I have a series of text boxes that are hidden, except one which users enter a value into. After a button is pressed, this text box disappears and the rest appear. From there, I want users to be able to enter different values into each text box. These values will be saved as variables. From there, users press a button and enter new values into the text boxes, until values have been entered into the text boxes for each number up to the first value entered into the hidden text box.
I'm not sure how else to explain this, but please let me know if you have any questions.
Correct me if im wrong. i think you want an input in different textbox?
Like textbox1 = 1, textbox2 = 2 and so on. If this is right then try this.
Lets try this to your 3 textbox for an example.
Private Sub Button_Click(sender As Object, e As EventArgs) Handles Button.Click
If TextBox1.Visible = True Then
If Trim(TextBox1.Text) <> "" Then
TextBox1.Visible = False
TextBox2.visible = True
Else
MsgBox("Required")
'or user error provider.
End If
Exit Sub
End If
If textbox2.visible = True Then
If Trim(TextBox2.Text) <> "" Then
TextBox2.Visible = False
TextBox3.visible = True
Else
MsgBox("Required")
'or user error provider.
End If
Exit Sub
End If
'and so on
End Sub
hope this is what you want. just basic but maybe usefull :)
This is the workflow of what you want to accomplish in JavaScript. VB.Net has similar functions to Visibility. https://msdn.microsoft.com/en-us/library/ms748821(v=vs.85).aspx?cs-save-lang=1&cs-lang=vb#code-snippet-2
In the visual editor you can create buttons and add Click events to them, this is basic so I won't tell you how to do it. Google if you can't.
var options = document.getElementsByClassName("options");
var optionsSetOne = document.getByClassName('optionsSetOne');
This will select all your options. Now that you have all your options selected and in a variable called options you can play around with the visibility, as the user progresses thought the buttons.
First I would set all my options to hidden with:
options.style.visibility = 'hidden';
After the users progresses and clicks the button, I will make the first set of the options visible. With:
$('#buttonOne').click(function(){
optionsSetOne.style.visibility = 'visible';
});
This is the basic workflow of what you want to accomplish, you have to figure out how to save all the information the user gives to you.

How do I save textboxes with tabs depending which tab is open?

I am trying to create a document writer in vb.net
So I decided to add a tab control, so I can create a new tab when I press a button. I would like to save the text in the tab that is open. I created a function the returns the text depending on what tab is open, but that only works for the two default tabs. I don't know how I would save if I've created a new tab.
The function to get the text is this:
Public Function getText() As String
If tabPage1.Visible = True Then
Return mainText.Text
ElseIf tabPage2.Visible = True Then
Return textBox1.Text
End If
End Function
I've done some research online, I've even looked at SharpDevelop's source code and I couldn't find anything.
Thanks in advance!
EDIT :
Public Sub setText(Byval value As String)
If tabPage1.Visible = True Then
mainText.Text = value
ElseIf tabPage2.Visible = True Then
textBox1.Text = value
End If
End Sub
Does anyone know how I would do an open feature determined on what tab is open (as before.)
If I understand you correctly, you are trying to have a textbox in each of your tabPages generated dynamically. If this is the case you could generalize your GetText function with this code
Function GetText() As String
If tabControl1.SelectedTab IsNot Nothing Then
Return tabControl1.SelectedTab.Controls.OfType(Of TextBox)().First().Text
End If
End Function
This requires that you have at least one textbox in each page (and your TabControl is named tabControl1). The SelectedTab property (if not nothing) is the current tabPage displayed by your tabControl

Assistance with a popup box?

So, I literally have one more thing to do to finish my Calculator, which is make an error box popup if the textbox is empty. Currently, it shows a message, saying an error has occurred. I want it to simply launch a popup if the textbox is empty, and a "Continue" button to close the window.
If you want a simple popup, try this:
if textboxNum1.Text = "" OR textboxNum2.Text = "" Then
MsgBox("Textboxes are empty!")
else
'Enter process here
End if
Or try this:
if(textboxNum1.Text = "" OR textboxNum2.Text = "") Then
MsgBox("Textboxes are empty!")
else
'Enter process here
End if

How To activate Menu in OK and UPDATE mode

I enabled some menu in right click event. The first time it works well. For example 'Add Row' menu is pressed, it adds row. Again I right click button, and it's not showing the menus which I enabled in right click event. I need to add row again and again.
How can I achieve this?
Private Sub SBO_Application_RightClickEvent(ByRef eventInfo As SAPbouiCOM.ContextMenuInfo, ByRef BubbleEvent As Boolean) Handles SBO_Application.RightClickEvent
Try
oForm = SBO_Application.Forms.Item("TRADING")
If (eventInfo.FormUID = "TRADING") Then
oCombo = oForm.Items.Item("1000002").Specific
Dim oMenus As SAPbouiCOM.Menus
oMenus = SBO_Application.Menus
oForm.EnableMenu("1287", True)
oForm.EnableMenu("1292", True)
oForm.EnableMenu("1293", True)
If (oCombo.Selected.Value = "Open") Then
oMenus.Item("1283").Enabled = True
Else
oMenus.Item("1283").Enabled = False
End If
End If
Catch ex As Exception
End Try
End Sub
based on the input that u gave with your post, there may be two chance of getting error.
for the first time u are adding the row perfectly but in next time it was not working.. so i think code was not perfectly handled. try to place the same code in before action false. and also try to catch the action result that u get at item event so that we can debug the issue clearly.
to enable the right click event menu we need to handle the right click menu options based on oform.mode Separately.
for example in purchase order screen we will get different menu in add more and find mode.