VB.net Datagrid

  • Thread starter Thread starter Shivang
  • Start date Start date
S

Shivang

Hello Everybody,

I am using Datagrid in VB.net. I don't want the auto
generation of rows in the datagrid (last row shouldnt be
the new row with empty values)..in addition to this the
datagrid should not be readonly..that is I should be
allowed to edit the values in datagrid.

You help will be appreciated.

Thanks.

Best,
Shivang.
 
You can make as many bound columns as you wish, you just have to add them in
the ASPX page. To edit a row, you can add the edit column and have an event
to control the editing. Try the examples from

http://www.wiley.com/extras/ado_net_xml_asp_net/

--
Gregory A. Beamer
MPV; MCP: +I, SE, SD, DBA

**********************************************************************
Think outside the box!
**********************************************************************
 
Thanks for the link.

Yes , you are right, the Datagrid for ASP.net and VB.net
is altogether different.

I need the solution for vb.net. I tried looking at the
msdn link..but couldn't find the exact solution. I am
using Dataset binded to the Datagrid though tablestyle
object. I need some function like Allownew (i.e for the
row) which can be set to false..

Please throw some light on this..Thanks

Shivang.
 
Sorry... I'm very uninformed when it comes to interacting with datasets. I
just work with object binding in my current project. Hopefully someone else
can help.

(Just for future reference... "VB.Net" includes both ASP.Net (Web forms) and
Windows Forms. Better to specify "ASP.Net" or "Winforms.")
 
Hi Shivang,
I had the same issue with the grid. In hindsight, i would
have used another grid, given all the headaches and late
nights this one gave me. That said:

To make the columns not read-only:
I used TableStyles objects to initially set up my grid
column styles. This has a readonly property that i was
able to set to false. heres and example. This is done
before binding the grid.
~~~~~~~~~~~~~~~~~~~~~~~~~~~~
'Create the table style object
Dim TSModule As New DataGridTableStyle()

'create the column style objects
Dim TCSymbol As New DataGridTextBoxColumn()

TSModule.MappingName = TABLE_NAME
Me.dgModuleMaint.CaptionText = strModuleName
Me.dgModuleMaint.AllowSorting = True
Me.dgModuleMaint.RowHeaderWidth = 20

'Symbol Column
TCSymbol.MappingName = "security_symbol"
TCSymbol.HeaderText = "Ticker"
TCSymbol.Width = enuGridColumnWidth.symbol
TCSymbol.Alignment = HorizontalAlignment.Left
TCSymbol.ReadOnly = True
'Add this to the style object
TSModule.GridColumnStyles.Add(TCSymbol)

' Add the DataGridTableStyle instance to
' the GridTableStylesCollection.
Me.dgModuleMaint.TableStyles.Add(TSModule)

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Now to get rid of the ending append rows. This was a
solutions i found somewhere on the web. By default the
DataView can remove this row, so if you get to the
dataview you can remove it.
Code follows:

'USER_ this little section removes the Append Row from
' the end of the datagrid
Dim cm As CurrencyManager = Me.BindingContext
(Me.dgModuleMaint.DataSource, Me.dgModuleMaint.DataMember)

Dim dv As DataView = cm.List
dv.AllowNew = False
'End remove append Row

where dgModuleMaint is the datagrid object. I had this
code immediately following the databinding.

Hope this helps
Mike
 
Hey Mike,

Thanks a lot! It works great! I don't understand why ;-)
it works..but then also..most important is it works.

Best,
Shivang.
 
Back
Top