Sunday, January 10, 2010

MSFlexGrid Veränderung einer Spaltenbreite

MSFlexGrid Veränderung einer Spaltenbreite

'------------- Anfang Projektdatei Project1.vbp -------------
' Die Komponente 'Microsoft FlexGrid Control 6.0 (SP6) (MSFLXGRD.OCX)' wird benötigt.

'--------- Anfang Formular "Form1" alias Form1.frm ---------
' Steuerelement: Flexible Tabelle "MSFlexGrid1"

Option Explicit

Private ColWidth() As Integer

Private Sub Form_Load()
Dim x%
ReDim ColWidth(MSFlexGrid1.Cols - 1)

For x = 0 To MSFlexGrid1.Cols - 1
ColWidth(x) = MSFlexGrid1.ColWidth(x)
Next x

GridhWnd = MSFlexGrid1.hWnd
Call Init
End Sub

Private Sub Form_Unload(Cancel As Integer)
Call Terminate
End Sub

Public Sub MSFlexGrid1_ColResize()
Dim x%, Dif&

With MSFlexGrid1
For x = 0 To .Cols - 1
Dif = .ColWidth(x) - ColWidth(x)
If Dif <> 0 Then
Me.Caption = "Spalte " & x & " um " & Dif _
& " Twips geändert"
ColWidth(x) = .ColWidth(x)
Exit For
End If
Next x
End With
End Sub
'---------- Ende Formular "Form1" alias Form1.frm ----------
'--------- Anfang Modul "Module1" alias Module1.bas ---------

Option Explicit

Public Declare Function CallWindowProc Lib "user32" Alias _
"CallWindowProcA" (ByVal lpPrevWndFunc As Long, ByVal _
hWnd As Long, ByVal Msg As Long, ByVal wParam As Long, _
ByVal lParam As Long) As Long

Public Declare Function SetWindowLong Lib "user32" Alias _
"SetWindowLongA" (ByVal hWnd As Long, ByVal nIndex _
As Long, ByVal dwNewLong As Long) As Long

Const GWL_WNDPROC = -4
Const WM_LBUTTONUP = &H202

Public GridhWnd&
Dim PrevProc&

Public Sub Init()
PrevProc = SetWindowLong(GridhWnd, GWL_WNDPROC, AddressOf WindowProc)
End Sub

Public Sub Terminate()
Dim Result&
Result = SetWindowLong(GridhWnd, GWL_WNDPROC, PrevProc)
End Sub

Function WindowProc(ByVal hWnd&, ByVal uMsg&, ByVal wParam&, ByVal _
lParam&) As Long
WindowProc = CallWindowProc(PrevProc, hWnd, uMsg, wParam, lParam)
If uMsg = WM_LBUTTONUP Then Form1.MSFlexGrid1_ColResize
End Function
'---------- Ende Modul "Module1" alias Module1.bas ----------
'-------------- Ende Projektdatei Project1.vbp --------------

Saturday, January 9, 2010

DataGrid Control for Visual Basic 6.0 Users

DataGrid Control for Visual Basic 6.0 Users
The DataGrid control in Visual Basic 6.0 is replaced by the Windows Forms DataGridView control in Visual Basic 2005. The names of some properties, methods, events, and constants are different, and in some cases there are differences in behavior.

Conceptual Differences

Data Binding
The Visual Basic 2005 DataGridView control does not need data-specific methods or events because all actions are performed through the data source. Because of this separation of presentation and data functionality, the data source can be changed with or without user interface input. Also, multiple controls bound to the same data source will always stay in sync.

Navigation
Properties for viewing and navigation in the DataGrid control (such as TabAction, EnterAction, AllowArrows, WrapCellPointer, and Scrollable) are no longer needed. For example, the grid functions as though the Scrollable property is set to True: If more data exists than can be displayed, a scroll bar appears automatically. Excel-style navigation through the grid is the default, allowing the user to move forward with the TAB key and backward with the SHIFT+TAB key combination. For more information, see Default Keyboard and Mouse Handling in the Windows Forms DataGridView Control.

Caption Property
In Visual Basic 6.0, the Caption property is used to display a title bar above the grid; if the Caption property is left empty, no title bar is displayed.

The Visual Basic 2005 DataGridView control does not support a title bar. However, you can achieve the same effect using a Label control.

Data Formatting
In Visual Basic 6.0, formatting data in the DataGrid control is handled using the DataFormat property and a StdDataFormat object. Formatting is applied on a column-by-column basis.

In the Visual Basic 2005 DataGridView control, formatting is accomplished using the Format property of a DataGridViewCellStyle object. Formatting can be applied to individual cells, columns, or rows. For more information, see Data Formatting in the Windows Forms DataGridView Control.

hWndEditor Property
In Visual Basic 6.0, the hWndEditor property is used to pass the window handle assigned to a DataGrid control's editing window to a Windows API call.

The Visual Basic 2005 DataGridView control does not have a separate window handle when in edit mode; instead, use the Handle property of the DataGridView control or any embedded edit controls.

MarqueeStyle Property
In Visual Basic 6.0, the MarqueeStyle property controls the appearance of a selected cell or row by changing the border style, inverting the foreground and background colors, or invoking an edit window.

There is no direct equivalent for the Visual Basic 2005 DataGridView control. However, you can achieve the same effect through a combination of the SelectionMode, CellBorderStyle, and Format properties. For more information, see Selection Modes in the Windows Forms DataGridView Control.

SelLength, SelStart, SelText Properties
In the Visual Basic 6.0 DataGrid control, when a cell enters edit mode, the SelLength, SelStart, and SelText properties can be used to set the initial position of the caret or to highlight a portion of the text in the cell.

In the Visual Basic 2005 DataGridView control, these properties no longer exist. The cells in the DataGridView control are based on the TextBox control; by adding code to the EditingControlShowing event handler you can access the SelectionLength, SelectionStart, and SelectedText properties of the underlying control.

Split Views
The Visual Basic 6.0 DataGrid control supports a split view, allowing the user to display the same data side-by-side. The Split object and the Split, Splits, and TabAcrossSplits properties control the ability to display a split view.

In the Visual Basic 2005 DataGridView control, these properties no longer exist. However, you can achieve the same effect using one or more SplitContainer controls and multiple DataGridView controls. To duplicate the functionality of the TabAcrossSplits property, you can use the StandardTab property of the DataGridView control.

Grid-Controls in visual basic

Betreff
Grid-Controls
Von
Lothar Geyer <Lothar.Geyer@EDV-Berater-Online.de>
Datum
12.10.2009 08:09:20
Ich trage mich mit dem Gedanken, von FlexGrid auf ein anderes Control
umzusteigen. Was könnt Ihr empfehlen und warum?

Lothar Geyer


Betreff
Re: Grid-Controls
Von
"robert madrian" <office@madrian.at>
Datum
12.10.2009 09:11:18
wenn es ein ActiveX Control sein soll dann Janus GridEX 2000 unter
http://www.janusys.com

robert


"Lothar Geyer" <Lothar.Geyer@EDV-Berater-Online.de> schrieb im Newsbeitrag
news:7jfvgfF33esk5U1@mid.individual.net...
> Ich trage mich mit dem Gedanken, von FlexGrid auf ein anderes Control
> umzusteigen. Was könnt Ihr empfehlen und warum?
>
> Lothar Geyer




Betreff
Re: Grid-Controls
Von
"Peter Götz" <gssg_nospam@gssg.de>
Datum
12.10.2009 09:56:48
Hallo Lothar,

> Ich trage mich mit dem Gedanken, von FlexGrid auf ein
> anderes Control umzusteigen.
FlexGrid und HFlexGrid haben mir nie wirklich gefallen.
Eine Menge bunter Schnickschnack und ansonsten
wenig flexibel und nicht gerade sonderlich schnell.

> Was könnt Ihr empfehlen und warum?

Dazu müssten man schon in etwa wissen, wofür ein
solches Grid genutzt werden soll.
Ich habe in allen meinen Anwendungen, die auch
zum Teil heute noch bei Kunden laufen das DataGrid(OleDb)
verwendet. Alles was dieses Grid nicht schon mitbrachte
konnte durch eigene Erweiterungen realisiert werden.

Warum ausgerechnet das DataGrid?
Weil ich
a) wg. schlechter Erfahrungen verbunden mit erheblichen
Kosten, grundsätzlich keine Controls von Drittanbietern
mehr verwende
und
b) das DataGrid sehr schnell ist und bisher für alle gestellten
Aufgaben recht gut angepasst/erweitert werden konnte.

Beides sind natürlich sehr persönliche Argumente, aber wie
schon erwähnt, wichtig wäre es, den konkreten Einsatzzweck
für ein solches Grid zu kennen.

Ich verwende allerdings VBclassic seit langem nicht mehr
für Neuentwicklungen. In Sachen Grids hat das .net-Framework
mit dem DataGrid und dem neueren DataGridView zwei
mächtige Controls zu bieten, mit denen ich bisher noch
jede denkbare Aufgabe lösen konnte, auch Dinge an die
mit VBclassic gar nicht zu denken war.

Gruß aus St.Georgen
Peter Götz
www.gssg.de (mit VB-Tipps u. Beispielprogrammen)




Betreff
Re: Grid-Controls
Von
"Wolf Wendel" <wowe@sofort-mail.de>
Datum
13.10.2009 10:58:03
> jede denkbare Aufgabe lösen konnte, auch Dinge an die
> mit VBclassic gar nicht zu denken war.

Was denn zum Bleistift? (Nein, will keine Diskussion lostreten, nur lernen.)



Betreff
Re: Grid-Controls
Von
"W. Wolf" <w.wolf.nosp@nospdommel.de>
Datum
13.10.2009 13:09:36
Hallo Peter,
"Peter Götz" <gssg_nospam@gssg.de> schrieb

[1]> DataGrid [...] bisher für alle gestellten
> Aufgaben recht gut angepasst/erweitert werden konnte.

[2]> DataGridView [...] jede denkbare Aufgabe lösen konnte,
> auch Dinge an die mit VBclassic gar nicht zu denken war.
>

Wenn das DG schon alles kann [1], warum sollte
ich dann Sachen machen wollen [2], an die gar nicht
zu denken wäre? Wie passt das denn zusammen? ;-)

Hallo Lothar,
verwende hier durchgehend das VSFlexGrid, also
den kostenpflichtigen großen Bruder vom FlexGrid
(Zoschke). Bin seit Jahren sehr zufieden...

Gruß
W. Wolf



---------------


Betreff
VB6 Komponenten in Win7
Von
=?Utf-8?B?UmFpbW8gQmVja2Vy?= <RaimoBecker@discussions.microsoft.com>
Datum
13.10.2009 12:07:02
Hallo NG,

ich habe in einer VB Anwendung VSFlexGrid und MSCOMM. Die werden unter
Windows7 beim Setup der Anwendung aber nicht korrekt registriert. Selbst im
VB6-Studio will es nicht gehen.
regsvr32-->Ausführen als Admin gibt mir zwar die Möglichkeit MSCOMM zu
registrieren aber VSFlex will immer noch nicht.
Habt ihr schon Erfahrungen mit VB6 und Windows7?

Ich poste das hier, weil ich noch keine Win7 NG gefunden habe - und das ja
doch mit VB zu tun hat.

Gruß aus Hannover

Raimo


Betreff
Re: VB6 Komponenten in Win7
Von
Ralf Schlegel <ralf.schlegel@vb-zentrum.de>
Datum
13.10.2009 17:30:14
Raimo Becker schrieb:
> Hallo NG,
>
> ich habe in einer VB Anwendung VSFlexGrid und MSCOMM. Die werden unter
> Windows7 beim Setup der Anwendung aber nicht korrekt registriert. Selbst im
> VB6-Studio will es nicht gehen.
> regsvr32-->Ausführen als Admin gibt mir zwar die Möglichkeit MSCOMM zu
> registrieren aber VSFlex will immer noch nicht.
> Habt ihr schon Erfahrungen mit VB6 und Windows7?
>
> Ich poste das hier, weil ich noch keine Win7 NG gefunden habe - und das ja
> doch mit VB zu tun hat.
>
> Gruß aus Hannover
>
> Raimo
Hallo Raimo,

habe mit Windows 7 Beta unter MS Virtual PC meine VB6 Setups und
Programme durchgetestet und keine Probleme festgestellt, die ich nicht
schon unter Vista hatte!
Ich benutze nach wie vor das gute alte VB6 Setup von MS.
Da dies auch im Quellcode vorliegt habe ich folgende Veränderung
durchgeführt:
- Setup prüft die Windows-Version
- Ist es Vista oder größer, so kann der Benutzer NICHT unter
"[C]:\Program Files" installieren!

Auf diese Weise umgehe ich das UAC und kann in meinem
Applikations-Verzeichnis auch problemlos Komponenten registrieren,
oder via Online-Update die eigene Applikation austauschen, usw.

Bevor jetzt wieder einige aufschreien von wegen "Standardverwurstung"
und "User-Einschränkung": wir diskutieren hier über eine 10 Jahre alte
Entwicklungsumgebung und wie man sie noch geringe Zeit am Leben erhält!

Deine beiden oben genannten Control kommen in meinen Anwendungen
allerding nicht zum Einsatz.

Liebe Grüße asu Wegberg

Ralf Schlegel
www.vb-zentrum.de


Betreff
Re: VB6 Komponenten in Win7
Von
=?Utf-8?B?UmFpbW8gQmVja2Vy?= <RaimoBecker@discussions.microsoft.com>
Datum
13.10.2009 21:32:04
Hallo Ralf,

...snip...

> - Setup prüft die Windows-Version
> - Ist es Vista oder größer, so kann der Benutzer NICHT unter
> "[C]:\Program Files" installieren!
> Auf diese Weise umgehe ich das UAC und kann in meinem
> Applikations-Verzeichnis auch problemlos Komponenten registrieren,
> oder via Online-Update die eigene Applikation austauschen, usw.

ich benutze Inno-Setup, aber die Idee klingt gut.
Da Win7 zu neu ist, finde ich aber keine geeignete Doku über die Rechte /
Pflichten. Werde also MSDN mal durchforsten müssen.

> Bevor jetzt wieder einige aufschreien von wegen "Standardverwurstung"
> und "User-Einschränkung": wir diskutieren hier über eine 10 Jahre alte
> Entwicklungsumgebung und wie man sie noch geringe Zeit am Leben erhält!

Ja das Ding ist ist sogar älter (also die Grundversion der exe) aber ich
denke das doch einige (!) Programme aus 1992- vor zehn Jahren laufen. Wenn
die alle umgeschrieben werden müssen. Da täte sich ein Markt auf...

> Deine beiden oben genannten Control kommen in meinen Anwendungen
> allerding nicht zum Einsatz.

MSComm halte ich für super (obwohl es da gute Alternativen geben soll),
VSFLex ist halt in der Anwendung drin und der Kunde scheut natürlich die
Investition den ganzen Code umzustellen.

Ich würds gerne machen.... :-)

Besten Dank erstmal
Raimo


Betreff
Re: VB6 Komponenten in Win7
Von
"Harald M. Genauck" <hmg.ng.entfernen@aboutvb.de>
Datum
14.10.2009 08:41:18
Hallo Raimo,

> ...snip...
> Da Win7 zu neu ist, finde ich aber keine geeignete Doku über die
> Rechte /
> Pflichten. Werde also MSDN mal durchforsten müssen.

Diesbezüglich hat sich bei Win7 nichts gegenüber Vista getan. Kannst
also auch nach Vista-bezogenen Informationen suchen.


Viele Grüße

Harald M. Genauck

"ABOUT Visual Basic" - http://www.aboutvb.de (Hrsg. + Redaktion)
"VISUAL STUDIO one" - http://www.visualstudio1.de (Chefredakteur)