My project is an user interface for an access 2003 file.
I need these things:
ComboBox that check the item
The user may click the arrow and select the item using the dropdown list and he can also enter the text.
The ComboBox must show a messagebox telling the value is wrong.
(Ive another unresolved thread for this http://forums.microsoft.com/msdn/ShowPost.aspx PostID=13251)
TextBox for Dates
TextBox for Double
TextBox for Integer
There's the format property for textboxes in Visual Basic 6 , why there's not a .net equivalent

missed controls/properties?
jthomas
Please try the following sample. Does this work for you
public Form1()
{
this.ClientSize = new System.Drawing.Size(292, 266);
this.Name = "Form1";
this.Load += new System.EventHandler(this.Form1_Load);
}
private void Form1_Load(object sender, EventArgs e)
{
ComboBox cb = new ComboBox();
cb.DropDownStyle = ComboBoxStyle.DropDownList;
cb.AutoCompleteSource = AutoCompleteSource.ListItems;
cb.AutoCompleteMode = AutoCompleteMode.Append;
cb.Location = new Point(10, 10);
Label lb = new Label();
lb.Location = new Point(10, 40);
DataTable dt = new DataTable();
dt.Columns.Add("ID", typeof(int));
dt.Columns.Add("Name");
dt.Rows.Add(0, "Dog");
dt.Rows.Add(1, "Monkey");
dt.Rows.Add(2, "Cat");
cb.DataSource = dt;
cb.DisplayMember = "Name";
cb.ValueMember = "ID";
Binding b = new Binding("SelectedValue", lb, "Text", true, DataSourceUpdateMode.OnPropertyChanged);
cb.DataBindings.Add(b);
this.Controls.Add(cb);
this.Controls.Add(lb);
b.WriteValue();
}
}
Joe
dnnguru
As for formatting text without data binding, if the MaskedTextBox and the DateTimePicker won't work for you then the best option may be to use data binding. To do this, you would need to create a property wrapper on the field you are trying to format and then bind the property wrapper.
Joe
Derek.Zhang
About the ComboBox, what I mean is this:
Ive a combo box with data binding and these are the values:
* Dog
* Cat
* Monkey
But the user can write Banana without problem!.
About the formatting, the formatstring doesn't work fine, I set it to dd/mm/yyyy, an it does't work.
And the MaskedTextBox doesn't check a thing, I can set the mask for dates (00/00/0000) but the user can set it to 99/99/9999! (it doesn't check if it's a valid date)
And what about decimals places .
I like my textboxes always show 2 decimal places.
Lucaz
dwitt
If I set the dropdownstyle to dropdownlist the user can't write 'Dog'.

(in the real context, the combobox's items count is 20+)
I checked the FormatString, I works ok for data bindings, thanks!
But what about formating for text without databinfing
bluewolf
If you want to be able to enter Banana, then I don't understand the code from your original code (below) - the code below prevents you from entering a new value in the ComboBox. Why are you trying to prevent the user from entering a new value (in OnLostFocus) if you also want them to allow them to enter a new value From your original post:
if( MyComboBox.Find(MyComboBox.Text) < 0 ) {
MessageBox.Show("This is not a valid value");
/* MyComboBox --- How can I restore the previous value */
}
As for the second issue, are you using data binding If so, FormatString works - post a sample of your issue and I'll take a look.
Thanks,
Joe
Vikas62
Joe
Deep Amberkar
The textbox doesn't have a FormatString property! (the ComboBox is ok).
And even if I use a ComboBox with Data Bindings, when I enter the data, there's not check...
Please, tell me if there is a control like the visual basic's textbox.
I can't wait more, I like to use .net but if there's not such control I think I'll move (back ) to visual basic 6.
Thanks a lot for your help!.
Pablo_IN_NZ
As for formatting, if you are data binding you can use the FormatString. If you are not using data binding, you may be able to use the MaskedTextBox and/or the DateTimePicker.
Joe
Jay T103328
I wonder if there is a property for that.
(sorry for my terrible English)
About the formatting, Ill check it again and I'll post the code later (I don't have it right now)
Thanks one more time Joe
D Danial
Perhaps, the problem is the data binding ->
source: myDataSet
show: Name
value: Id
: none
I can change the what it shows, but the selected item doesnt change.
Example:
Table
1 Dog
2 Monkey
3 Cat
The comboBox starts with "Dog" (the first)
I can change the dog text to "Banana" without problem, but the selected value is still 1.