How to block/lock a textbox? - visual-studio-2013

I'm using visual studio 2013. The text in textbox3 of my program can be edited by the user. I want to fix text in it.To do that user must be unable to edit the text in that textbox. How to do that.

Add following code and you'll get a window with TextBox1 disabled and TextBox2 enabled.
TextBox1.Text = "ContentOfTextBox1" 'fill text box
TextBox1.Enabled = False 'disable text box
or
TextBox1.Text = "ContentOfTextBox1";
TextBox1.Enabled = false;

Set .ReadOnly property to True.As an example,
TextBox1.ReadOnly = True
Here the user can't edit textbox1.

Related

How to create an input box with iron python using windows.forms?

For a simple Gui in Iron python I need a simple dialog box with an input text field and OK and cancel button and return value of input text, equivalent to Visual Basic input box.
So basically, dialog pops up, you enter value, hit OK an dialog box closes and returns value to calling function.
I could not find anything in the windows forms library.
I guess you need to create a form yourself from scratch, using text box, etc..?
Is there really no input box in winforms?
If so, could anyone share how to create one with winforms and iron python?
Thanks for help!
Nils
I am new to Ironpython and GUI programming, therefore the following solution might not be elegant neither complete, but it seems to work.
Any ideas for improvement?
import clr
clr.AddReference("System.Windows.Forms")
clr.AddReference("System.Drawing")
from System.Drawing import Point
from System.Windows.Forms import Button, Form, Label, TextBox, FormStartPosition, FormBorderStyle
class MyInputBoxClass(Form):
def __init__(self,message, title, defaultText):
#Creates Input Box with text Input Field
#define form
self.Text = title
self.Width = 600
self.Height = 110
self.StartPosition = FormStartPosition.CenterScreen;
self.FormBorderStyle = FormBorderStyle.FixedDialog
self.MinimizeBox = False;
self.MaximizeBox = False;
#define label
self.label = Label()
self.label.Text = message
self.label.Location = Point(10, 10)
self.label.Height = 30
self.label.Width = 250
#define text box
self.textbox = TextBox()
self.textbox.Text = defaultText
self.textbox.Location = Point(10, 40)
self.textbox.Width = 500
#define button
self.button1 = Button()
self.button1.Text = 'ok'
self.button1.Location = Point(510, 40)
self.AcceptButton = self.button1
#define dialog result
self.button1.DialogResult = DialogResult.OK;
#add controls to form
self.Controls.Add(self.label)
self.Controls.Add(self.textbox)
self.Controls.Add(self.button1)
#Todo: Handel Close Input Box Event
def MyInputBox(message, title, defaultText):
form = MyInputBoxClass(message, title, defaultText)
form.ShowDialog()
#Application.Run(form2) #this is not working, you need ShowDialog for modal form
return form.textbox.Text
def TestGui(analysis_obj):
#This function is beeing called from API
inputTextFromDialogBox = MyInputBox("Please Enter Example Text","ExampleInputBox","Its working but I'm not convinced")
print ("Input Box Return Value is '%s'"%inputTextFromDialogBox)
#ExtAPI.Log.WriteMessage("Input Box Return Value is '%s'"%inputTextFromDialogBox)

Print Preview in ReportViewer display blank screen

Below is the code for the new page setting:
Dim newPageSettings As New PageSettings
newPageSettings.Margins = New Margins(20, 20, 20, 20)
newPageSettings.Landscape = True
Dim paperSize As PaperSize = New PaperSize()
paperSize.RawKind = PaperKind.A4
newPageSettings.PaperSize = paperSize
ReportViewer1.SetPageSettings(newPageSettings)
Me.ReportViewer1.RefreshReport()
After I debug the system and click Print Preview in ReportViewer, the screen display as below:
I seriously don't know how this happen. Please help. Thanks.
I have already found a solution for above issue. Instead of using coding to setup setting for print preview, I change the Report Setting in rdlc. Please see below picture for more info:

VB6: Combo box style 2. Text Property behaviour

One of our VB6 project form is having a combo box. It's style is set to 2(Drop-down List Box).
When style is set to 2, its Text property becomes read-only. We cannot assign value to it.
But in our project some one has written code to assign string to Text property, and is working fine.
combobox1.Text = "Something" 'working
If i create a same kind of combo box with same properties, i am not able to assign string to text property.
I am getting error runtime error 383 'text' property is read-only
combobox2.Text = "Something" 'Not working
Can anyone help me understanding what i am missing.
The reason why someone else code worked is because they had the dropdown combo property selected and not the dropdown list. You need to add items to the combo list and then set the listindex to 0 as per below -
Combo1.AddItem "MyComboCaptionHere"
Combo1.AddItem "Hi"
Combo1.AddItem "There"
Combo1.ListIndex = 0
This will show a "caption" of MyComboCaptionHere.

Inserting images in Access database as hyperlink

I'm trying to insert an image path into an Access database. I have a hyperlink field named logo, and I'm using this code to browse for images:
Dim dialog As FileDialog
Set dialog = Application.FileDialog(msoFileDialogFilePicker)
With dialog
.AllowMultiSelect = False
.Title = "Select A File To Use As A Logo"
.Filters.Clear
.Filters.Add "Images", "*.gif; *.jpg; *.jpeg;*.bmp;*.png"
.ButtonName = "Use This File"
If .Show = True Then
Me.im1 = .SelectedItems.Item(1)
End If
End With
im1 is an unbound textbox used to view the path. The problem is that it's displaying the file path as text, not as a hyperlink. I'd like to display the file name as a hyperlink in my form in im1. Is this possible?
Text is text. If you want something to show up as a hyperlink you need to tell your textbox that's what it's doing. It can't guess.
im1.IsHyperlink=True
However, The easier thing to do is probably to use a Label instead of a textbox. Set the .HyperlinkAddress property to your link address

How to reset the box

Using masked box in the form
masked1.mask = ##:##
In form load, masked1 display as __:__
Once user enter the values like 08:00 then reset means it should display again like this __:__
How to do this?
To clear a MaskEditBox you set the Text property to an empty string, however when the PromptInclude property is True you'll get an error. I would suggest writing a Sub method that you can call when you want to clear it.
Private Sub ClearMaskedEditBox(ByVal vMaskEditBox As MaskEdBox)
Dim strMask As String
strMask = vMaskEditBox.Mask 'save the current mask
vMaskEditBox.Mask = "" 'clear the control's mask
vMaskEditBox.Text = "" 'clear the text
vMaskEditBox.Mask = strMask 'reset the mask
End Sub
To use you call the Sub with the MaskEditBox control you want to clear.
Call ClearMaskedEditBox(masked1)

Resources