
donnacha
Avatar/Signature-
Posts
189 -
Joined
-
Last visited
Content Type
Profiles
Forums
Blogs
Events
Articles
Resources
Downloads
Gallery
Everything posted by donnacha
-
At a minimum you should not put the password in the config file. Add that to the string in the file. Generally all you really need in the file is the database location, the name is probably standard, so the remainder can be built up in code. How are you going to encrypt the string as this will probably need to be done in advance and you may not know the location until deployment, but you could still do the encryption as part of a custom action in the deployment and add it to the config file.
-
Isin't it just using the append mode for FileOpen
-
Aren't you now tying yourself to Kadmos instead of Autocad. I would be wary of that. At least Autocad viewers will keep uptodate and are probably not too expensive. There is another option, to convert the files to DWF format and then display them.
-
Here is the remainder of the class '---------------------------------------------------------------------- ' Helper Methods '---------------------------------------------------------------------- Private ReadOnly Property DataGridTableGridLineWidth() As Integer Get If Me.DataGridTableStyle.GridLineStyle = DataGridLineStyle.Solid Then Return 1 Else Return 0 End If End Get End Property Private Sub EndEdit() InEdit = False Invalidate() End Sub Private Function GetText(ByVal Value As Object) As String If Value Is System.DBNull.Value Then Return NullText If Not Value Is Nothing Then Return Value.ToString Else Return String.Empty End If End Function Private Sub HideComboBox() If Combo.Focused Then Me.DataGridTableStyle.DataGrid.Focus() End If Combo.Visible = False End Sub Private Sub RollBack() Combo.Text = OldVal End Sub Private Sub PaintText(ByVal g As Graphics, _ ByVal Bounds As Rectangle, _ ByVal Text As String, _ ByVal AlignToRight As Boolean) Dim BackBrush As Brush = New SolidBrush(Me.DataGridTableStyle.BackColor) Dim ForeBrush As Brush = New SolidBrush(Me.DataGridTableStyle.ForeColor) PaintText(g, Bounds, Text, BackBrush, ForeBrush, AlignToRight) End Sub Private Sub PaintText(ByVal g As Graphics, _ ByVal TextBounds As Rectangle, _ ByVal Text As String, _ ByVal BackBrush As Brush, _ ByVal ForeBrush As Brush, _ ByVal AlignToRight As Boolean) Dim Rect As Rectangle = TextBounds Dim RectF As RectangleF = RectF.op_Implicit(Rect) ' Convert to RectangleF Dim Format As StringFormat = New StringFormat() If AlignToRight Then Format.FormatFlags = StringFormatFlags.DirectionRightToLeft End If Select Case Me.Alignment Case Is = HorizontalAlignment.Left Format.Alignment = StringAlignment.Near Case Is = HorizontalAlignment.Right Format.Alignment = StringAlignment.Far Case Is = HorizontalAlignment.Center Format.Alignment = StringAlignment.Center End Select Format.FormatFlags = Format.FormatFlags Or StringFormatFlags.NoWrap g.FillRectangle(Brush:=BackBrush, Rect:=Rect) Rect.Offset(0, yMargin) Rect.Height -= yMargin g.DrawString(Text, Me.DataGridTableStyle.DataGrid.Font, ForeBrush, RectF, Format) Format.Dispose() End Sub End Class
-
I am not sure why you need to look at the key events so much, but try this class and see if it helps. '------------------------------------------------------------------------- Option Strict On Option Explicit On Imports System.Collections Imports System.ComponentModel Imports System.Drawing Imports System.Windows.Forms Imports System.Data Public Class DataGridComboBox Inherits ComboBox Public Sub New() MyBase.New() End Sub Public isInEditOrNavigateMode As Boolean = True End Class Public Class DataGridComboBoxColumn 'DataGridComboBoxColumnStyle Inherits DataGridColumnStyle Public TextBox As New TextBox() ' Temp added by donnacha 17/11/04 to allow compilation with old appli code Public BackGroundColor As Color ' '' Public ReadOnly Property ComboBox() As ComboBox ' '' Get Try Return Me.Combo Catch ex As Exception Finally End Try End Get End Property Private cm As CurrencyManager Private iCurrentRow As Integer '**************************************************** ' UI constants Private xMargin As Integer = 2 Private yMargin As Integer = 1 Private Combo As DataGridComboBox Private _DisplayMember As String Private _ValueMember As String ' ' Used to track editing state ' Private OldVal As String = String.Empty Private InEdit As Boolean = False ' ' Create a new column - DisplayMember, ValueMember ' Passed by ordinal ' Public Sub New(ByRef DataSource As DataTable, _ ByVal DisplayMember As Integer, _ ByVal ValueMember As Integer) Me.cm = Nothing '--------- Combo = New DataGridComboBox() _DisplayMember = DataSource.Columns.Item(index:=DisplayMember).ToString _ValueMember = DataSource.Columns.Item(index:=ValueMember).ToString With Combo .Visible = False .DataSource = DataSource .DisplayMember = _DisplayMember .ValueMember = _ValueMember End With End Sub ' ' Create a new column - DisplayMember, ValueMember ' passed by string ' Public Sub New(ByRef DataSource As DataTable, _ ByVal DisplayMember As String, _ ByVal ValueMember As String) Me.cm = Nothing '--------- Combo = New DataGridComboBox() With Combo .Visible = False .DataSource = DataSource .DisplayMember = DisplayMember .ValueMember = ValueMember End With End Sub '------------------------------------------------------ ' Methods overridden from DataGridColumnStyle '------------------------------------------------------ ' Abort Changes ' Protected Overloads Overrides Sub Abort(ByVal RowNum As Integer) Debug.WriteLine("Abort()") RollBack() HideComboBox() EndEdit() End Sub ' ' Commit Changes ' Protected Overloads Overrides Function Commit(ByVal DataSource As CurrencyManager, _ ByVal RowNum As Integer) As Boolean HideComboBox() If Not InEdit Then Return True End If Try Dim Value As Object = Combo.SelectedValue If NullText.Equals(Value) Then Value = Convert.DBNull End If SetColumnValueAtRow(DataSource, RowNum, Value) Catch e As Exception RollBack() Return False End Try EndEdit() Return True End Function ' ' Remove focus ' Protected Overloads Overrides Sub ConcedeFocus() Me.Commit(Me.cm, Me.iCurrentRow) Combo.Visible = False End Sub ' ' Edit Grid ' Protected Overloads Overrides Sub Edit(ByVal Source As CurrencyManager, _ ByVal Rownum As Integer, _ ByVal Bounds As Rectangle, _ ByVal [ReadOnly] As Boolean, _ ByVal InstantText As String, _ ByVal CellIsVisible As Boolean) Me.iCurrentRow = Rownum '---- Me.cm = Source '----- '--------------------------- Combo.Text = String.Empty Dim OriginalBounds As Rectangle = Bounds OldVal = Combo.Text If CellIsVisible Then Bounds.Offset(xMargin, yMargin) Bounds.Width -= xMargin * 2 Bounds.Height -= yMargin Combo.Bounds = Bounds Combo.Visible = True Else Combo.Bounds = OriginalBounds Combo.Visible = False End If Combo.SelectedValue = GetText(GetColumnValueAtRow(Source, Rownum)) If Not InstantText Is Nothing Then Combo.SelectedValue = InstantText End If Combo.RightToLeft = Me.DataGridTableStyle.DataGrid.RightToLeft Combo.Focus() If InstantText Is Nothing Then Combo.SelectAll() Else Dim [End] As Integer = Combo.Text.Length Combo.Select([End], 0) End If If Combo.Visible Then DataGridTableStyle.DataGrid.Invalidate(OriginalBounds) End If InEdit = True End Sub Protected Overloads Overrides Function GetMinimumHeight() As Integer ' ' Set the minimum height to the height of the combobox ' Return Combo.PreferredHeight + yMargin End Function Protected Overloads Overrides Function GetPreferredHeight(ByVal g As Graphics, _ ByVal Value As Object) As Integer Debug.WriteLine("GetPreferredHeight()") Dim NewLineIndex As Integer = 0 Dim NewLines As Integer = 0 Dim ValueString As String = Me.GetText(Value) Do While NewLineIndex <> -1 NewLineIndex = ValueString.IndexOf("r\n", NewLineIndex + 1) NewLines += 1 End While Loop Return FontHeight * NewLines + yMargin End Function Protected Overloads Overrides Function GetPreferredSize(ByVal g As Graphics, _ ByVal Value As Object) As Size Dim Extents As Size = Size.Ceiling(g.MeasureString(GetText(Value), _ Me.DataGridTableStyle.DataGrid.Font)) Extents.Width += xMargin * 2 + DataGridTableGridLineWidth Extents.Height += yMargin Return Extents End Function Protected Overloads Overrides Sub Paint(ByVal g As Graphics, _ ByVal Bounds As Rectangle, _ ByVal Source As CurrencyManager, _ ByVal RowNum As Integer) Paint(g, Bounds, Source, RowNum, False) End Sub Protected Overloads Overrides Sub Paint(ByVal g As Graphics, _ ByVal Bounds As Rectangle, _ ByVal Source As CurrencyManager, _ ByVal RowNum As Integer, _ ByVal AlignToRight As Boolean) Dim Text As String = GetText(GetColumnValueAtRow(Source, RowNum)) PaintText(g, Bounds, Text, AlignToRight) End Sub Protected Overloads Sub Paint(ByVal g As Graphics, _ ByVal Bounds As Rectangle, _ ByVal Source As CurrencyManager, _ ByVal RowNum As Integer, _ ByVal BackBrush As Brush, _ ByVal ForeBrush As Brush, _ ByVal AlignToRight As Boolean) Dim Text As String = GetText(GetColumnValueAtRow(Source, RowNum)) PaintText(g, Bounds, Text, BackBrush, ForeBrush, AlignToRight) End Sub Protected Overloads Overrides Sub SetDataGridInColumn(ByVal Value As DataGrid) MyBase.SetDataGridInColumn(Value) If Not (Combo.Parent Is Value) Then If Not (Combo.Parent Is Nothing) Then Combo.Parent.Controls.Remove(Combo) End If End If If Not (Value Is Nothing) Then Value.Controls.Add(Combo) End Sub Protected Overloads Overrides Sub UpdateUI(ByVal Source As CurrencyManager, _ ByVal RowNum As Integer, ByVal InstantText As String) Combo.Text = GetText(GetColumnValueAtRow(Source, RowNum)) If Not (InstantText Is Nothing) Then Combo.Text = InstantText End If End Sub
-
Creating a dropdown in Excel using VB.NET
donnacha replied to jcallinan's topic in Interoperation / Office Integration
Why don't you use an excel template file and put the drop down in that where you need it. I don't know if you can do it the way you are trying to do it. -
It is fairly easy, Autocad provide a DWG viewer, I think it is called VoloView. If you install this and then in your application you can just launch a process which is just the DWG file name and your system should reckognise the file type an launch the viewer. I think they also have a DXF one. If you want to go the full hog, they provide sample C++ applications. Use the 1st method, it works. They may also have a browser plug-in that you could use.
-
Datagrid & Combobox Dataaset updataing problem
donnacha replied to donnacha's topic in Windows Forms
Hi folks, I found the solution, apparently the problem has nothing to do with the derived class, it lies instead with the datagrid. The solution is thanks to http://www.error-bank.com/microsoft.public.dotnet.languages.vb.controls/4644_Thread.aspx (why could't I have found that a month ago, oh the pain, the pain....) Private Sub MainGrid_CurrentCellChanged(ByVal sender As Object, ByVal e As System.EventArgs) Handles MainGrid.CurrentCellChanged Me.BindingContext(MainGrid.DataSource, MainGrid.DataMember).EndCurrentEdit() End Sub -
It is fairly simple, just use SystemInformation.ComputerName
-
Hi folks, I have a weird problem when I am using a datagridcomboboxcolumn. In my grid I have several columns one of which is a combobox. When I enter data (1st entry for a new row) in any of the columns other than the combobox column, a new row is created in the grid and datasource. When I enter date in the combobol column as the 1st entry for a new row, the data is accepted and appears in the grid, but no new row is created in the datagrid/dataset. Has anybody come across anything like this before. Am I failing to handle some event ? I am using VS 2000 and VB. The combox box is a derived class, I have tried it out with a variety of samples and I get the sam result each time. Any help would be great.
-
Hi folks, I have recently installed the latest XP patch which is a security update for MDAC (KB832483) and I am having problems with it as sometimes when a connection is opened to the database from my VB.NET application (Access 2000) the CPU goes to 100% load with Winlogin.exe taking all the CPU. It goes away after several minutes. It doesn't happen everytime, which is more worrying. I am using VS 2002 & Framewotk 1.0. Has anybody else experienced this problem or know what might be causing it. :confused: :confused:
-
Be carefull decimal.tostring(xx) does not always give the answer you would expect, you may need to add decimal.tostring(xx,NumberFormatInfo) to get the correct result.
-
Hi folks, I am using Access 2000 and VS2000 and I have got problem updating the database which I have narrowed down to the size of the tabel definition. Does anybody know what the maximum size allowed is for database tables that VS can work with. :confused:
-
Hi folks, for those of ye that have long searched for a solution to the word wrap problem or autosize row height in windows forms datagrid, here is yier XMAS present. I stumbled across this solution "Advanced DataGrid sizing" by user "Woutervu" (another frustated datagrid user) on http://www.gotdotnet.com/community/usersamples/ see link to sample here. http://www.gotdotnet.com/Community/UserSamples/Details.aspx?SampleGuid=4ef489d1-b5f8-4c91-b2fe-905f5ca9f16e It is in C# and the demo seems to work fine. I haven't integrated it yet, but it looks straigh forward. Lets hope it works as well as the demo. :cool:
-
Surely to God I'm not the only one to want to do this?!?!
donnacha replied to MikeP's topic in Windows Forms
What are you trying to do, display multiple columns from the dataset in the ckeckedlistbox or display a single column from the dataset in multiple columns in the ckeckedlistbox. If it is the 1st case then you could do it 2 ways, 1 - On creating the dataset, add a new column which combines multiple columns of the dataset and then as this as the display member in the ckeckedlistbox. 2 - I believe you could use an owner drawn ckeckedlistbox and in the draw/paint method combine the data from the multiple dataset rows. (Not the easiest way of doing things.) If it is the 2nd case then you have problems, I don't think it has a multi-column option and even if it dif you would run into the problem of the ckeckedlistbox not being able to wrap a text line if it is too large. ( If you find a solution to that problem I would live to hear about it as it has bugged me for a long while). Your only solution in this case is to creat your own control from a combination of checkboxes, not nice to have to do it, but not as bad as one might think. Hope this helped..... -
Yeah, Decimal.Add/Subtract/Multiply combined with Decimal.Todouble should help. e.g. Dim a,b,c as double b = 1234.555 c = 0234.554 a = Decimal.ToDouble(Decimal.Subtract(b,c)) should give a double of 1000.001
-
Hi folks, isin't this annoying, you would think the system would be smart enough to avoid this. I had the same problem in doing additions. I wanted to check againt 100% and all the individual bits added up to 100 but the result was 100.000000000000001 so my comparison did not work. I have found a solution which I find irritating to have to do, but you do what you need to do to get the thing to work even if it is daft. The solution uses Decimal as a middle man to get around the rounding (pardon the pun). e.g. dim res, a,b,c as double a = 75.25 b = 24.74999 c = 00.00001 res = Decimal.ToDouble(Decimal.Add(a,Decimal.Add(b,c))) The result should be 100.0 You should be able to solve yier problem with the Decimal.Subtract or Decimal.Multiply etc... Lets hope next year is less .NET bug ridden.....
-
Hi folks, isin't this annoying, you would think the system would be smart enough to avoid this. I had the same problem in doing additions. I wanted to check againt 100% and all the individual bits added up to 100 but the result was 100.000000000000001 so my comparison did not work. I have found a solution which I find irritating to have to do, but you do what you need to do to get the thing to work even if it is daft. The solution uses Decimal as a middle man to get around the rounding (pardon the pun). e.g. dim res, a,b,c as double a = 75.25 b = 24.74999 c = 00.00001 res = Decimal.ToDouble(Decimal.Add(a,Decimal.Add(b,c))) The result should be 100.0 You should be able to solve yier problem with the Decimal.Subtract Lets hope next year is less .NET bug ridden.....
-
Hi voodoochile, try doing the bitmap.dispose before the bitmap = nothing etc.. and see if this helps. I would leave the GC.collect call as well.
-
Problem solved at last. It was based on the DropDownArrows parameter of the ToolBar instead of the type of individual button on the toolbar. When I set this parameter to false, I no longer get the dropdown arrow at the right of the button and clicking on the button shows the menu.
-
Hi folks, does anybody know how to adjust the height of an item in a checkedlistbox. I know it can be done for an ordinary list box usint eh ItemHeight, but it doesn't seem to be accessible for the checkedlistbox version (ItemHeight is readonly). The reason I need this is that if I increase the font size from 8 to 10, the control at runtime clips the bottom of letters such as y,q,p,g. I am using MS Sans Serif as it is the clearest fornt to use in this case. Any suggestions are welcome.:-\
-
Hi folks, I have a toolbar in my application that contains a dropdown button with an attached menu. The dropdown menu part works fine, but the button still acts as a button as when the main part of the button is clicked it generates a button clicked event like all the other buttons. Does anybody know how to stop this or how to get the button click to display the drop down menu in the same way as clicking the dropdown part of the button. Thanks :rolleyes:
-
It must be possible to do this ourselves without using external components. Have a look at thi sample and see if it helps. I would love to solve this for myself as well. http://www.gotdotnet.com/Community/UserSamples/Download.aspx?SampleGuid=86B1E31F-C717-4C21-9721-61B9ADB38E9B
-
Hi Robby, thanks for that, but again this is for web/asp. It isin't available for windows controls. And as far as I know the same word wrap problem does not exist for web style grids. Thanks