473,503 Members | 1,655 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

easy grid editing ? ? ? (equivalent to msflexgrid)

can someone explain how to simply populate a grid in .net ? the way i
understand it, there is no more msflexgrid, and instead is this new
control that has to be tied to a dataset, and it is a real pain to
work with if you just want to throw some values in a grid and edit
them with a textbox. i don't want to persist anything in a database, i
just need a fast cheap and easy grid in memory that i can work with!

i had functions in vb6 that would insert (tab & vbcrlf) delimited text
into a grid, and vice versa. it was super easy. if you clicked on the
grid, it would superimpose a textbox you could type in, and on lost
focus, the textbox contents got copied into the appropriate cell.

is there some existing code to do this in vb.net easily?
(i stress EASILY! it's 2004, this kinda stuff is supposed to get
easier as technology advances is it not!)

many thanks

-----

vb6 code i want to find equivalent to:

'this function converts tab/vbcrlf delim text to a msflexgrid
Function fn_sCopyGridToText(ByRef grdTemp As Object, ByVal iFirstRow
As Integer, ByVal iFirstCol As Integer) As String

'this function converts contents of msflexgrid to delim (eg
tab/vbcrlf) text
Sub subCopyTextToGrid(ByRef sString As String, ByRef grdTemp As
Object, ByVal iFirstRow As Integer, ByVal iFirstCol As Integer, ByVal
sRowDelim As String, ByVal sColDelim As String, ByVal bClearGrid As
Boolean)

'when user clicks msflexgrid, puts a textbox over the cell they
clicked on so they can edit text in cell
Private Sub grdValues_Click()
Dim sGridDisplay As String

' SAVE POSITION
g_dictValues.Item("iGridRow") = grdValues.Row
g_dictValues.Item("iGridCol") = grdValues.Col

' GET VALUE
sGridDisplay = fn_No_Empty(grdValues.TextMatrix(grdValues.Row,
grdValues.Col), "", True) ' get value in grid

' BUILD TEXT BOX, PLACE OVER CURRENT CELL
txtEdit.Text = sGridDisplay ' copy text of current cell into edit
box
txtEdit.Top = grdValues.Top + grdValues.CellTop
txtEdit.Left = grdValues.Left + grdValues.CellLeft
txtEdit.Width = grdValues.CellWidth
txtEdit.Height = grdValues.CellHeight
txtEdit.Text = grdValues.Text
g_dictValues.Item("sOriginalText") = grdValues.Text
txtEdit.Visible = True
txtEdit.SetFocus

End Sub ' grdValues_Click

'when user exits textbox, save contents in grid
Private Sub txtEdit_LostFocus()

' ================================================== =================
' SAVE TEXT IN GRID
grdValues.TextMatrix(g_dictValues.Item("iGridRow") ,
g_dictValues.Item("iGridCol")) = txtEdit.Text
'grdValues.TextMatrix(g_iGridRow, g_iGridCol)
txtEdit.Visible = False

End Sub ' txtEdit_LostFocus
Nov 20 '05 #1
1 4906
Hi Mad,

The answer on your question is very simple.

The only thing you have to know is that using a datagrid is as well using a
table where the datatable is the most easy one for that.

To show you how easy I type it in here beneath without checking so watch
typos, I assume you have pulled a datagrid1 on your form

I hope this helps?

Cor

\\\
dim dt as new datatable
dt.columns.add("Mad")
dt.columns.add("Cor")
for i as integer = 0 to 9
dim dr as datarow = dt.newrow
dr(i)(0)= i.tostring
dr(i)(1)= chr(i + 64)
dt.rows.add(dr)
next
datagrid1.datasource = dt
///
can someone explain how to simply populate a grid in .net ? the way i
understand it, there is no more msflexgrid, and instead is this new
control that has to be tied to a dataset, and it is a real pain to
work with if you just want to throw some values in a grid and edit
them with a textbox. i don't want to persist anything in a database, i
just need a fast cheap and easy grid in memory that i can work with!

i had functions in vb6 that would insert (tab & vbcrlf) delimited text
into a grid, and vice versa. it was super easy. if you clicked on the
grid, it would superimpose a textbox you could type in, and on lost
focus, the textbox contents got copied into the appropriate cell.

is there some existing code to do this in vb.net easily?
(i stress EASILY! it's 2004, this kinda stuff is supposed to get
easier as technology advances is it not!)

many thanks

-----

vb6 code i want to find equivalent to:

'this function converts tab/vbcrlf delim text to a msflexgrid
Function fn_sCopyGridToText(ByRef grdTemp As Object, ByVal iFirstRow
As Integer, ByVal iFirstCol As Integer) As String

'this function converts contents of msflexgrid to delim (eg
tab/vbcrlf) text
Sub subCopyTextToGrid(ByRef sString As String, ByRef grdTemp As
Object, ByVal iFirstRow As Integer, ByVal iFirstCol As Integer, ByVal
sRowDelim As String, ByVal sColDelim As String, ByVal bClearGrid As
Boolean)

'when user clicks msflexgrid, puts a textbox over the cell they
clicked on so they can edit text in cell
Private Sub grdValues_Click()
Dim sGridDisplay As String

' SAVE POSITION
g_dictValues.Item("iGridRow") = grdValues.Row
g_dictValues.Item("iGridCol") = grdValues.Col

' GET VALUE
sGridDisplay = fn_No_Empty(grdValues.TextMatrix(grdValues.Row,
grdValues.Col), "", True) ' get value in grid

' BUILD TEXT BOX, PLACE OVER CURRENT CELL
txtEdit.Text = sGridDisplay ' copy text of current cell into edit
box
txtEdit.Top = grdValues.Top + grdValues.CellTop
txtEdit.Left = grdValues.Left + grdValues.CellLeft
txtEdit.Width = grdValues.CellWidth
txtEdit.Height = grdValues.CellHeight
txtEdit.Text = grdValues.Text
g_dictValues.Item("sOriginalText") = grdValues.Text
txtEdit.Visible = True
txtEdit.SetFocus

End Sub ' grdValues_Click

'when user exits textbox, save contents in grid
Private Sub txtEdit_LostFocus()

' ================================================== =================
' SAVE TEXT IN GRID
grdValues.TextMatrix(g_dictValues.Item("iGridRow") ,
g_dictValues.Item("iGridCol")) = txtEdit.Text
'grdValues.TextMatrix(g_iGridRow, g_iGridCol)
txtEdit.Visible = False

End Sub ' txtEdit_LostFocus

Nov 20 '05 #2

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
4937
by: Bhom | last post by:
I am trying to create a grid on a form that looks like the 'Split Transaction' grid in Quicken - it allows drop down controls in various cells of grid to make a selection, and then stores the text...
2
2428
by: build | last post by:
G'day all, I want to load comma sep text files and display it in a grid. I'd like something simple and lightweight. Don't need to edit it in grid, I could do that in textboxes if required. tia...
1
740
by: Mad Scientist Jr | last post by:
can someone explain how to simply populate a grid in .net ? the way i understand it, there is no more msflexgrid, and instead is this new control that has to be tied to a dataset, and it is a real...
4
2003
by: Stanley Sin | last post by:
Dear all , Could anyone suggest some good 3rd party grid control of visual basic.net 2005? Any free? Thanks in advance. BR,
0
1630
by: Steven | last post by:
Hi All, Is there any method to copy the MSFlexGrid data (including the text color, cell background color etc) to the microsoft excel work sheet? By using the clipboard function, I can read the...
0
1419
by: vaavachi | last post by:
Hi, I would like to allow users to select from a drop down list for all cells in, let say, column 3. How can I add a combo box to that column? I read something about a "button" property of...
3
11995
by: Andrus | last post by:
In VCSE 2008 B2 I created WPF form, added grid an ran it. Form does not show grid. Where to find sample which allows to edit object collection returned by Linq-SQL in WPF grid ? Andrus.
4
1903
by: Gilles Ganault | last post by:
Hello For business apps, we need a good, solid, bound- and unbound grid widget. In VB Classic apps, we use ComponentOne's VSFlexGrid widget www.componentone.com I was wondering if there are...
2
7859
by: MiziaQ | last post by:
Hey, how can I allow the user to edit ANY cell from any row and column in an msflexgrid ? I found the following code, but it only allows input for the first column. Thank you in advance. Private...
0
7201
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
7278
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
7328
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
5578
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
4672
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...
0
3166
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The...
0
1510
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated ...
1
734
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
0
379
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.