Home All Groups Group Topic Archive Search About

Disable a text box when it's not adding new row?

Author
16 Feb 2007 10:10 PM
Nick nkw
I want to enable a text box only when it's in "add new" status. The
BindingSource.Position just return a number. Any good way to do it?

Thanks,

Author
16 Feb 2007 11:21 PM
ClayB
Maybe you could enable the TextBox in the BindingSource.AddingNew
event.

==============
Clay Burch
Syncfusion, Inc.
Author
20 Feb 2007 5:22 PM
Nick nkw
The problem is when to disable the TextBox after adding? It sounds not
proper events of BindingSource suitable.

ClayB wrote:
Show quote
> Maybe you could enable the TextBox in the BindingSource.AddingNew
> event.
>
> ==============
> Clay Burch
> Syncfusion, Inc.
>
>
Author
16 Feb 2007 11:28 PM
RobinS
How do you *know* it's in AddNew status? When they add a row to the list or
datatable? Or is that what you're asking?

Robin S.
-------------------------
Show quote
"Nick nkw" <nick.y.w***@hotmail.com> wrote in message
news:OMnrWdhUHHA.4744@TK2MSFTNGP02.phx.gbl...
>I want to enable a text box only when it's in "add new" status. The
>BindingSource.Position just return a number. Any good way to do it?
>
> Thanks,
Author
17 Feb 2007 2:10 AM
msdn
I know one way to tell, check if th position of bindingSource is larger than
the counts of the table. But it seems not work well on multiple users
environment.


Show quote
"RobinS" <RobinS@NoSpam.yah.none> wrote in message
news:n76dnexzUJ-eo0vYnZ2dnUVZ_ragnZ2d@comcast.com...
> How do you *know* it's in AddNew status? When they add a row to the list
> or datatable? Or is that what you're asking?
>
> Robin S.
> -------------------------
> "Nick nkw" <nick.y.w***@hotmail.com> wrote in message
> news:OMnrWdhUHHA.4744@TK2MSFTNGP02.phx.gbl...
>>I want to enable a text box only when it's in "add new" status. The
>>BindingSource.Position just return a number. Any good way to do it?
>>
>> Thanks,
>
>
Author
17 Feb 2007 2:49 AM
Bart Mermuys
Hi,

"Nick nkw" <nick.y.w***@hotmail.com> wrote in message
news:OMnrWdhUHHA.4744@TK2MSFTNGP02.phx.gbl...
>I want to enable a text box only when it's in "add new" status. The
>BindingSource.Position just return a number. Any good way to do it?

If you are using DataSet/DataTable/DataView as a DataSource for the
BindingSource, then something like this might work:

private bindingSource_CurrentChanged(...)
{
  DataRowView drv  = (DataRowView)bindingSource.Current;
  textBox.Enabled = drv.IsNew;
}

HTH,
Greetings



Show quote
>
> Thanks,
Author
19 Feb 2007 2:46 AM
Earl
It really helps to use a New button also, something like the following. But
a better solution is to set up a comprehensive method that includes all
buttons and controls that are enabled/disabled as one.

Private Sub btnNew_Click(ByVal sender As Object, ByVal e As
System.EventArgs) Handles btnNew.Click
BindingSource.AddNew()
    txtQuantity.Enabled = true
    btnNew.Enabled = false
    btnSave.Enabled = true
End Sub

Private Sub btnSave_Click(ByVal sender As Object, ByVal e As
System.EventArgs) Handles btnSave.Click
SaveRoutine()
    txtQuantity.Enabled = false
    btnSave.Enabled = false
End Sub

Show quote
"Nick nkw" <nick.y.w***@hotmail.com> wrote in message
news:OMnrWdhUHHA.4744@TK2MSFTNGP02.phx.gbl...
>I want to enable a text box only when it's in "add new" status. The
>BindingSource.Position just return a number. Any good way to do it?
>
> Thanks,

AddThis Social Bookmark Button