I want to edit the columns of this component but don't know how.
Anyone knows?
WiseGuy
Printable View
I want to edit the columns of this component but don't know how.
Anyone knows?
WiseGuy
You'll have to create a textbox, without borders.
place it on your form, and set visibility to false.
when the user clicks on the flexgrid,
place the textbox over that particular cell
Here's an example:
Code:txtflex.Top = flex.Top + flex.CellTop
txtflex.Left = flex.Left + flex.CellLeft
txtflex.Visible = True
txtflex.Text = flex.Text
txtflex.Width = flex.CellWidth
txtflex.Height = flex.CellHeight
I hope you understood this. txtflex is a textbox I've placed, and I've named my flex grid as flex
Sorry, you cant. check out Microsoft Library. Use the MSFlex Grid
not the MSHFlex Grid, that one is read-only.
If you have any other questions you can e-mail me or post them here.
ok do what jwmoore says, and I forgot to add,
in the txtflex_validate event, that's where you will be making your additions to the flexgrid.
flex.textmatrix(flex.row, flex.col) = txtflex.text
HTH
hmm, this works ... got if off a thread ... dont remeber from who
but you can edit the msflexgrid ... give it a try
VB Code:
Private Sub MSFlexGrid1_KeyPress(KeyAscii As Integer) With MSFlexGrid1 Select Case KeyAscii Case 8: 'IF KEY IS BACKSPACE THEN If .Text <> "" Then .Text = _ Left$(.Text, (Len(.Text) - 1)) Case 13: 'IF KEY IS ENTER THEN Select Case .Col Case Is < (.Cols - 1): SendKeys "{right}" Case (.Cols - 1): If (.Row + 1) = .Rows Then .Rows = .Rows + 1 End If SendKeys "{home}" + "{down}" End Select Case Else .Text = .Text + Chr$(KeyAscii) 'write your own keyascii Validations under 'commented lines Select Case .Col Case 0, 1, 2: 'if (your condition(s)) then 'accept only charectors 'Else ' keyascii=0 'End If Case Else: End Select End Select End With End Sub
I'll do what JWmoore says that'll be a lot easier hehe.
Thank you both!
WiseGuy
Sucks when they create a control for data access and you cant update through it. Almost seems useless. It looks nice.
that code i posted works with MSHFlexgrid too, by the way
How do you update the data then. This would take alot of coding not sure if its possible.
Muddy, it looks like that code you provided is for editting in run-time, I just want to edit the columns in build time
And JWMoore I don't see how I could edit the columns of the MSflexgrid either!
WiseGuy
You want to edit the columns at design time? What are you trying to do exactly. Are you trying to load data from a database?
Please explain.
I'm sorry for not being clear enough, yes I want to edit the columns at designtime. The grid is used to load a lot of data on. But if I can't edit the columns there are a lot of weird names that are automatically generated using the SQL statement I provided.
Here's the code I use (if that's of any help)
VB Code:
Set cn = New ADODB.Connection cn.ConnectionString = "Data Source=spijsDB;User ID=spijs;Password=spijs;" cn.Open Set rs = New ADODB.Recordset grdDataGrid.Refresh cn.CursorLocation = adUseClient strSQL = "select a.artikelID, a.productcode, a.artikelnaam, b.typecode, TO_CHAR(a.tolerantiepluskg), c.celnaam, TO_CHAR(a.natdroogverh) from artikelen a, artikeltype b, cellen c" rs.Open strSQL, cn Set grdDataGrid.DataSource = rs grdDataGrid.Refresh
WiseGuy
just equate mshflexgrid.textmatrix(x,y) to the database fieldsQuote:
Originally posted by jwmoore2001
How do you update the data then. This would take alot of coding not sure if its possible.
binding a datagrid is easier though
some folks seem to hate binding for some reason (havent quite figured out why)
I myself prefer flex grids for the flexibility.Quote:
Originally posted by Muddy
just equate mshflexgrid.textmatrix(x,y) to the database fields
binding a datagrid is easier though
some folks seem to hate binding for some reason (havent quite figured out why)
I would also like to know how to add data there at design time. I did not know you could do that, and was under the impression it's not possible.
thats a Datagrid :DQuote:
Originally posted by WiseGuy
I'm sorry for not being clear enough, yes I want to edit the columns at designtime. The grid is used to load a lot of data on. But if I can't edit the columns there are a lot of weird names that are automatically generated using the SQL statement I provided.
Here's the code I use (if that's of any help)
VB Code:
Set cn = New ADODB.Connection cn.ConnectionString = "Data Source=spijsDB;User ID=spijs;Password=spijs;" cn.Open Set rs = New ADODB.Recordset grdDataGrid.Refresh cn.CursorLocation = adUseClient strSQL = "select a.artikelID, a.productcode, a.artikelnaam, b.typecode, TO_CHAR(a.tolerantiepluskg), c.celnaam, TO_CHAR(a.natdroogverh) from artikelen a, artikeltype b, cellen c" rs.Open strSQL, cn Set grdDataGrid.DataSource = rs grdDataGrid.Refresh
WiseGuy
Sir Frog,Quote:
Originally posted by mendhak
I myself prefer flex grids for the flexibility.
I would also like to know how to add data there at design time. I did not know you could do that, and was under the impression it's not possible.
I dont think you can at design time. im not sure why you would need to do that as you could always load it up when the form loads ...
no it's not, it's the name of a datagrid.Quote:
thats a Datagrid :D
WiseGuy
If you are trying to change the column captions on a Datagrid .. then right click on it (design time) select properties. Filp through the tabs till you find it ...Quote:
Originally posted by WiseGuy
I'm sorry for not being clear enough, yes I want to edit the columns at designtime. The grid is used to load a lot of data on. But if I can't edit the columns there are a lot of weird names that are automatically generated using the SQL statement I provided.
Here's the code I use (if that's of any help)
VB Code:
Set cn = New ADODB.Connection cn.ConnectionString = "Data Source=spijsDB;User ID=spijs;Password=spijs;" cn.Open Set rs = New ADODB.Recordset grdDataGrid.Refresh cn.CursorLocation = adUseClient strSQL = "select a.artikelID, a.productcode, a.artikelnaam, b.typecode, TO_CHAR(a.tolerantiepluskg), c.celnaam, TO_CHAR(a.natdroogverh) from artikelen a, artikeltype b, cellen c" rs.Open strSQL, cn Set grdDataGrid.DataSource = rs grdDataGrid.Refresh
WiseGuy
Wiseguy :DQuote:
Originally posted by WiseGuy
no it's not, it's the name of a datagrid.
WiseGuy
Yeah WiseGuy indeed ;)
but if it would be a simple as you said :
The I would have found it by now but i didn'tQuote:
Filp through the tabs till you find it ...
b.t.w. this is almost a chatsession LOL
The WiseGuy
You called me sir frog! thanks :)
as muddy said, It's not possible. i just tried doing that on my project, I found nothing.
Like I've explained above, with a flexgrid, you load at runtime, and you edit at runtime.
The reason it's called a flexgrid, is because, it's just there. and you just code it's entire working, in your own way. (flexibility)
Heres a pictureQuote:
Originally posted by WiseGuy
Yeah WiseGuy indeed ;)
but if it would be a simple as you said :
The I would have found it by now but i didn't
b.t.w. this is almost a chatsession LOL
The WiseGuy
I think it is a chat, right.
Anyway with the datagrid, out of curiosity, why do you want to update the grid at design time?
Could you give me an example of how to edit a column at runtime?
WiseGuy
Sorry If I sound confused.Quote:
Originally posted by WiseGuy
Could you give me an example of how to edit a column at runtime?
WiseGuy
edit a column for a datagrid or a flexgrid?
Dear Mr. Muddy,
I thought I said I wanted to use the Flex grid and not the datagrid!
I know how it is done in a datagrid.
WiseGuy
I'd like an example of how to edit a column of a flexgrid at runtime
WiseGuy
Quote:
Originally posted by Muddy
If you are trying to change the column captions on a Datagrid .. then right click on it (design time) select properties. Filp through the tabs till you find it ...
;)Quote:
Wiseguy
but if it would be a simple as you said :
quote:
--------------------------------------------------------------------------------
Filp through the tabs till you find it ...
--------------------------------------------------------------------------------
The I would have found it by now but i didn't
I thought I showed you...
go back and look at my post at the beginning of this thread.
that's how you get the textbox in place.
to do the editing, in the texbox validate event,
one more question.Code:private sub txtflex_validate()
flex.textmatrix(flex.row, flex.col) = txtflex.text
end sub
are you trying to connect to a database? in that case, it would be different.
sorry if we are confusing you.
Quote:
Originally posted by WiseGuy
I'd like an example of how to edit a column of a flexgrid at runtime
WiseGuy
VB Code:
MSFlexGrid1.TextMatrix(0, 1) = 999
I think he's getting frustrated. He did say he knows how to modify column fields in a DataGrid at design time. It's not possible to modify the FlexGrid Columns at design time.
I figured out, how to add a row, but not a column. Still working on it. This is at run-time for a MSHflexgrid.
Well I'm not getting frustrated ;)
It's just that it's all a bit confusing because it's going all so fast
WiseGuy
if yu just want to type it in to edit it at run time ... see the code i posted above (5th post in this thread). it works for msflexgrid OR mshflexgrid
ok... try whatever we've given you here.
then relax, come back here, and tell us if you run into problems.
Muddy is right. You can edit the flex grid with that code from above. Using the textmatrix is the only way your going to be able to modify any of the cells (including headers) and only at run-time.
No forget the run-time for a moment, I'm just talking about designtime for now, okey.
Here's the situation again:
I'm connecting to an Oracle DB and I want to show a lot of data in the grid. Preferebly an msFlexgrid or an MSHFlexgrid.
The problem is, that if I don't do anything with the columnheaders the I get weird names.
I want to give my own names to the column headers so that it looks a bit better.
I hope that this will clear out some questionmarks
The WiseGuy
I'm not sure if this works after you have bound the grid, but give it a shot:
MSFlexGrid1.TextMatrix(0, 1) = "Column 1 Header"
Other than that I am out of ideas.
Good Luck!
Muddy, how can you bind the flexgrid at runtime? You are confusing me as well :confused:Quote:
Originally posted by Muddy
I'm not sure if this works after you have bound the grid, but give it a shot:
MSFlexGrid1.TextMatrix(0, 1) = "Column 1 Header"
Other than that I am out of ideas.
Good Luck!
I mean
how can you bind a flexgrid.
(forget the runtime part)
Muddy code does work, I'm just trying to find out when to trigger the code :S
WiseGuy
Try mine :DQuote:
Originally posted by WiseGuy
Muddy code does work, I'm just trying to find out when to trigger the code :S
WiseGuy
Everything works fine now, This is how my code looks like right now:
VB Code:
Set cn = New ADODB.Connection cn.ConnectionString = "Data Source=spijsDB;User ID=spijs;Password=spijs;" cn.Open Set rs = New ADODB.Recordset grdDataGrid.Refresh cn.CursorLocation = adUseServer strSQL = "select a.artikelID, a.productcode, a.artikelnaam, b.typecode, TO_CHAR(a.tolerantiepluskg), c.celnaam, TO_CHAR(a.natdroogverh) from artikelen a, artikeltype b, cellen c" rs.Open strSQL, cn Set grdDataGrid.DataSource = rs grdDataGrid.Refresh grdDataGrid.TextMatrix(0, 1) = "Nummer" grdDataGrid.TextMatrix(0, 2) = "Product Code" grdDataGrid.TextMatrix(0, 3) = "Artikel" grdDataGrid.TextMatrix(0, 4) = "Artikeltype" grdDataGrid.TextMatrix(0, 5) = "Tolerantie (KG)" grdDataGrid.TextMatrix(0, 6) = "Celnaam" grdDataGrid.TextMatrix(0, 7) = "Nat/Droog verhouding"
Sir Frog,Quote:
Originally posted by mendhak
I mean
how can you bind a flexgrid.
(forget the runtime part)
When the Datasource property is set, I consider the grid "bound". Of course I could very well have my terminology screwed up.
I mean, after all, I am just a bluesman impersonating a programmer. :D
Bluesman,Quote:
Originally posted by Muddy
Sir Frog,
When the Datasource property is set, I consider the grid "bound". Of course I could very well have my terminology screwed up.
I mean, after all, I am just a bluesman impersonating a programmer. :D
previously you confused me.
Now you're scaring me! :eek: (kidding!)
OK, I checked, and flexgrids don't have a datasource property. Are we talking about the same flexgrid here? MSFLEXGRID. That's what I have. I have to connect it to the db, and manipulate everything through code.
How is it that you talk about a datasource property which I know not of?
(btw, lara stays here! :D)
Sir Frog,Quote:
Originally posted by mendhak
Bluesman,
previously you confused me.
Now you're scaring me! :eek: (kidding!)
OK, I checked, and flexgrids don't have a datasource property. Are we talking about the same flexgrid here? MSFLEXGRID. That's what I have. I have to connect it to the db, and manipulate everything through code.
How is it that you talk about a datasource property which I know not of?
(btw, lara stays here! :D)
After reading your post and sig I am convinced of 2 things:
1) you are stoned
2) i am stupid
:D LOL
My MSFlexGrid has a datasource property. So does WiseGuy's ... check out the code he posted
Answer: 1. I'm stoned. (just a bit)Quote:
Originally posted by Muddy
Sir Frog,
After reading your post and sig I am convinced of 2 things:
1) you are stoned
2) i am stupid
:D LOL
My MSFlexGrid has a datasource property. So does WiseGuy's ... check out the code he posted
I checked AGAIN... and for some strange reason, it's THERE!!! (conspiracy?????)
Just one more quick question, if you're still looking at this post...
the datasource applies for things like ADODC and the normal datacontrol, right?
Hope you're looking, otherwise, I'll put up a new post after 10 minutes if you don't answer.
Quote:
Originally posted by mendhak
(btw, lara stays here! :D)
Hang on and I'll wake her up and give her the message :D
[QUOTE]Originally posted by mendhak
(Just one more quick question, if you're still looking at this post...
the datasource applies for things like ADODC and the normal datacontrol, right?
those or an ADO Recordset ...
Muddy, the below works fine but it doens't save any changes I make in the MSFlexGrid. How do you save any changes??
Lintz.
Quote:
Originally posted by Muddy
hmm, this works ... got if off a thread ... dont remeber from who
but you can edit the msflexgrid ... give it a try
VB Code:
Private Sub MSFlexGrid1_KeyPress(KeyAscii As Integer) With MSFlexGrid1 Select Case KeyAscii Case 8: 'IF KEY IS BACKSPACE THEN If .Text <> "" Then .Text = _ Left$(.Text, (Len(.Text) - 1)) Case 13: 'IF KEY IS ENTER THEN Select Case .Col Case Is < (.Cols - 1): SendKeys "{right}" Case (.Cols - 1): If (.Row + 1) = .Rows Then .Rows = .Rows + 1 End If SendKeys "{home}" + "{down}" End Select Case Else .Text = .Text + Chr$(KeyAscii) 'write your own keyascii Validations under 'commented lines Select Case .Col Case 0, 1, 2: 'if (your condition(s)) then 'accept only charectors 'Else ' keyascii=0 'End If Case Else: End Select End Select End With End Sub
I suppose you would have to write the cells to some sort of file (delimited text, mdb, csv. etc)
That's right Muddy
The back end of my app is run by an Access DB. Once I populate the MSFlexGrid how do I then save any changes to a particular record in my DB??