|
Hi,
Some friends here oredi taught me how to open a program from a vb project. But is it possible to make the opened program located in a box in the vb project interface?
|
|
|
|
|
szevy_suez wrote: But is it possible to make the opened program located in a box
What do you mean by open program locate in a box?
|
|
|
|
|
Erm, it's like defining a border/frame in the interface where the program called will be opened sitted in the border/frame
|
|
|
|
|
Thank you very much for your respond. But I still can't figure out about your meaning relate to your question. If possible, please try draw a picture of what you want and send e-mail as an attachment file to my e-mail address: roathkanel@yahoo.com
|
|
|
|
|
No, it isn't. You can't make another application be a child window, or control, of your app.
Dave Kreskowiak
Microsoft MVP - Visual Basic
|
|
|
|
|
Hello Friends,
I have been working on ASP.NET for the last 2 and half years. The
bad part of my experience is I have been working alone on all of the
projects and there was no peer around who knows .NET or OOP. So where
ever I go I just get to implement the ones I know or udnerstand. In all
of the projects I never implemented any of the OOP techiniques at all
but just a water fall approach like a classic ASP programming. Except
calling a connection string web.config file and put that in a DL and
BL to call stored proc and put the results in a Datasets or datareaders
as needed. Other than this my mind has no experience on how to take
full advantage of OOP. So I am just looking for a few pages of document
that explains a small project with just 2,3 database table objects and
how to design the components in OOP in .NET and catogorize the
components with the application of Abstraction, Inheritance,
Polymorphism, encapsulation, interfaces(when and why to create them)
and also the remaining things if I have forgotten any thing to mention
here.
Some one could help me with finding a resource like that. In a single
sentence I am confident enough to build web applications using ASP.NET
1.x/2.0 but feel handicapped in using and implementing OOP paradigm in
the application I work on. My objective is once the database folks are
done with database designing job and once its I have every thing ready
from the database I should be able to sit and design components looking
at the datamodel and design the components in .NET using OOP apradigm.
Thats my objective is. How and where do I get this kind of
understanding. I am not looking to happen this over night but a
starting point about how I need to start thinking or working from and
how?
Any help is greatly appriciated,
Thanks in advance,
-L
|
|
|
|
|
Pick up just about any book on VB.NET and you'll find what you're looking for.
Dave Kreskowiak
Microsoft MVP - Visual Basic
|
|
|
|
|
I used to have the same problem, except in windows applications. I would do ALL of my development in Visual Basic 6.0 because that was how i was used to think. Eventually I forced myself to develop an entire application .NET and it did wonders for me. BAsically my advice would be to make sure you understand primarily what all the OOP components are: classes, interfaces, inheritence, overloading etc. and before you start writing your classes, draw a basic diagram of your class structure. Work off of this and then at some point you'll realize your original construct could be done much more efficiently. This is when you refactor all of your code and redesign your object structure. Keep repeating this and you'll find that you gain a better and better understanding of when to use OOP and how. Of course, don't do this for a really big / corporate application, but more as a hobby thing.
Regards,
Tristan Jones
|
|
|
|
|
Hi all,
I am working with some CSV files
basicly the workflow is
CSV->datatable->datasource-> bindingsource -> display as data grid view
I have two such bindingsource
one of users by department
one of users by bill
what i would like to do is run through a loop so that any new users that show up on the bill are put into the datagrid view with ??? as there department ( so i can fill it in later)
( i later use teh department to break the bill up into amount by department)
I have the Loop down i just am not sure of the command to add a new row to the binding source
Any pointers you could give me would be awsome
code
************************************************************************
Public Sub addusers()
Dim userRowIndex As Integer
Dim name As String
For Each invoiceRow As DataRowView In Me.invoicebindingsource
userRowIndex = Me.userbindingsource.Find("Name", invoiceRow("Name"))
name = invoiceRow("name")
If userRowIndex <> -1 AndAlso Me.userbindingsource(userRowIndex)("Name") = name Then
Else
CType(userbindingsource, DataRowView)
End If
Next invoiceRow
End Sub
|
|
|
|
|
Im on the right path now but still having some trouble
It still wont do it automaticly loops through once then quits
Dim userRowIndex As Integer
'Dim currentRow As DataRowView = DirectCast(Me.userbindingsource.Current, DataRowView)
Dim newRow As DataRowView = DirectCast(userbindingsource.AddNew(), DataRowView)
Dim name As String
For Each invoiceRow As DataRowView In Me.invoicebindingsource
userRowIndex = Me.userbindingsource.Find("Name", invoiceRow("Name"))
name = invoiceRow("name")
If userRowIndex <> -1 AndAlso Me.userbindingsource(userRowIndex)("Name") = name Then
MessageBox.Show(invoiceRow("name") & " already exists")
Else
newRow("Name") = name
newRow("Department") = "???"
End If
Next invoiceRow
|
|
|
|
|
If I correctly understand what you are trying to do, this should work for you:
For Each userRow As DataRowView in Me.userbindingsource
Dim name as String = userRow.Item("name")
If Me.invoicebindingsource.Find("name",name) = -1 Then
Me.invoicebindingsource.AddNew
Dim newRecord as DataRowView = CType(me.invoicebindingsource.Current, DataRowView)
newRecord.Item("name") = name
newRecord.Item("department") = "???"
Me.invoicebindingsource.EndEdit
Else
msgbox(name & "already exists")
End If
Next
This will iterate through the users and check for a name match in every record of the invoice table. If a match is found, it shows the message box; if not, it creates a new record and sets the name and dept fields. Hope this helps.
|
|
|
|
|
Hi
I have downloaded some code (below) from this site, converted it to VB .NET and tried it and nothing happens with the datagrid(No columns are shown). Explain what is wrong and what I have to do, please. I have also tried to Import the namespace Hamster and it didn't work. Explain what I have to do to make it work.
Fia
Imports System
Imports System.Windows.Forms
Imports System.Drawing
Imports System.Data
Imports System.Collections
'I had to comment the namespace to correct an error, it said it coudn't find the namespace
'Namespace Hamster.Common
Public Class DataGridComboBoxColumn
Inherits DataGridColumnStyle
Private _xMargin As Integer = 2
Private _yMargin As Integer = 1
Private _comboBox As ComboBox
Private _oldValue As String = ""
Private _inEdit As Boolean = False
Private _dataTable As DataTable
Private _displayMember, _valueMember As String
Public Sub New(ByVal colName As String, ByVal dataSource As DataTable, ByVal
displayMember As String, ByVal valueMember As String, ByVal dataGrid As
DataGrid)
_comboBox = New ComboBox
_comboBox.Visible = False
_comboBox.DataSource = dataSource
_dataTable = dataSource
_comboBox.DisplayMember = displayMember
_displayMember = displayMember
_valueMember = valueMember
_comboBox.ValueMember = valueMember
_comboBox.DropDownStyle = ComboBoxStyle.DropDownList
Dim _graphicsContext As Graphics = dataGrid.CreateGraphics()
Dim _widest As Single = 0
Dim _stringSize As New SizeF(0, 0)
Dim dr As DataRow
For Each dr In dataSource.Rows
_stringSize = _graphicsContext.MeasureString(dr(displayMember).ToString(),
dataGrid.Font)
If _stringSize.Width > _widest Then
_widest = _stringSize.Width
End If
Next dr
_comboBox.DropDownWidth = CInt(Math.Ceiling(_widest))
Me.Width = _comboBox.DropDownWidth + 25 ' Add the space for the dropdown
arrow
Me.MappingName = colName
Me.HeaderText = colName
dataGrid.Controls.Add(_comboBox)
End Sub 'New
Protected Overrides Sub Abort(ByVal rowNum As Integer)
_inEdit = False
_comboBox.Hide()
End Sub 'Abort
Protected Overrides Function Commit(ByVal dataSource As CurrencyManager,
ByVal rowNum As Integer) As Boolean
If Not _inEdit Then
Return True
End If
Try
Dim _value As Object = _comboBox.SelectedValue
If NullText.Equals(_value) Then
_value = System.Convert.DBNull
End If
Me.SetColumnValueAtRow(dataSource, rowNum, _value)
Catch
Finally
_inEdit = False
_comboBox.Hide()
End Try
Return True
End Function 'Commit
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)
_comboBox.Text = ""
Dim _originalBounds As Rectangle = bounds
_oldValue = _comboBox.Text
If Not cellIsVisible Then
Return
End If
bounds.Offset(_xMargin, _yMargin)
bounds.Width -= _xMargin * 2
bounds.Height -= _yMargin
_comboBox.Bounds = bounds
_comboBox.Visible = True
_comboBox.SelectedValue = GetText(GetColumnValueAtRow([source], rowNum))
If Not (instantText Is Nothing) Then
_comboBox.SelectedValue = instantText
Dim [End] As Integer = _comboBox.Text.Length
_comboBox.Select([End], 0)
Else
_comboBox.SelectAll()
End If
_inEdit = True
End Sub 'Edit
Protected Overrides Function GetMinimumHeight() As Integer
Return _comboBox.PreferredHeight + _yMargin
End Function 'GetMinimumHeight
Protected Overrides Function GetPreferredHeight(ByVal g As Graphics, ByVal
val As Object) As Integer
Return FontHeight + _yMargin
End Function 'GetPreferredHeight
Protected Overrides Function GetPreferredSize(ByVal g As Graphics, ByVal val
As Object) As Size
Dim _extents As Size = Size.Ceiling(g.MeasureString(GetText(val),
Me.DataGridTableStyle.DataGrid.Font))
_extents.Width += _xMargin * 2
_extents.Height += _yMargin
Return _extents
End Function 'GetPreferredSize
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 'Paint
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))
Dim dr As DataRow
For Each dr In _dataTable.Rows
If dr(_valueMember).ToString() = _text Then
_text = dr(_displayMember).ToString()
Exit For
End If
Next dr
PaintText(g, bounds, _text, alignToRight)
End Sub 'Paint
' Helper functions
Private Sub PaintText(ByVal g As Graphics, ByVal bounds As Rectangle, ByVal
[text] As String, ByVal alignToRight As Boolean)
Dim _backBrush = New SolidBrush(Me.DataGridTableStyle.BackColor)
Dim _foreBrush = New SolidBrush(Me.DataGridTableStyle.ForeColor)
Dim _rect As Rectangle = bounds
Dim _rectF As RectangleF = RectangleF.op_Implicit(_rect)
Dim _format As New StringFormat
If alignToRight Then
_format.FormatFlags = StringFormatFlags.DirectionRightToLeft
End If
Select Case Me.Alignment
Case HorizontalAlignment.Left
_format.Alignment = StringAlignment.Near
Case HorizontalAlignment.Right
_format.Alignment = StringAlignment.Far
Case HorizontalAlignment.Center
_format.Alignment = StringAlignment.Center
End Select
_format.FormatFlags = StringFormatFlags.NoWrap
g.FillRectangle(_backBrush, _rect)
_rect.Offset(0, _yMargin)
_rect.Height -= _yMargin
g.DrawString([text], Me.DataGridTableStyle.DataGrid.Font, _foreBrush,
_rectF, _format)
_format.Dispose()
End Sub 'PaintText
Private Function GetText(ByVal val As Object) As String
If val Is System.DBNull.Value Then
Return Me.NullText
End If
If Not (val Is Nothing) Then
Return val.ToString()
Else
Return String.Empty
End If
End Function 'GetText
End Class 'DataGridComboBoxColumn
'End Namespace 'Hamster.Common
-------------------------------------------------------------
'Imports Hamster.Common
Public Class Form1
Inherits System.Windows.Forms.Form
Private Sub Form1_Load(ByVal sender As Object, ByVal e As System.EventArgs)
Handles MyBase.Load
Dim ts As New DataGridTableStyle
ts.MappingName = "Columns"
Dim AccessDataTypes As New DataTable
AccessDataTypes.Columns.Add(New DataColumn("Number", GetType(Integer)))
AccessDataTypes.Columns.Add(New DataColumn("Name", GetType(String)))
AccessDataTypes.Rows.Add(New Object() {3, "Numeric"})
AccessDataTypes.Rows.Add(New Object() {130, "Text"})
Dim c1 As New DataGridComboBoxColumn("Type", AccessDataTypes, "Name",
"Number", theGrid)
c1.NullText = "3"
ts.GridColumnStyles.Add(c1)
End Sub
End Class
|
|
|
|
|
The "Hamster" namespace, obviously, isn't part of the .NET Framework. It's something the author of the article wrote and should be included in the downloads attached to the article.
It looks like this this is doing a bunch of custom drawing, but without the missing pieces, it's impossible to say what's wrong. Your best source of information on this code would be the person who write the article. The bottom of every article has a discussion board. Post your question there.
Dave Kreskowiak
Microsoft MVP - Visual Basic
|
|
|
|
|
Hi, I am trying to work out how to write some code that will generate a selection of 6 numbers which are random but each number be unique, I know that you can add the RANDOMIZE to the form load which I have done and this will produce a random selection of numbers but the numbers are not always unique i.e. a number may appear twice and this is where I am getting stuck.
Help!!!;)
|
|
|
|
|
The simplest (and least efficient) way to do this would be to generate the numbers, compare them all and if you get any duplicates, generate a new number for one of the duplicates and check again.
Regards,
Tristan Jones
|
|
|
|
|
Hi Tristan,
Thanks, I don't suppose you can give me a clue with where to start with the coding (yes I am completing new at this)
This is a sample of the coding I have to gentrate the numbers and the Randomize:
Private Sub btnGenerate_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnGenerate.Click
lblLottoBall1.Text = CStr(Int(Rnd() * 49)) + 1
lblLottoBall2.Text = CStr(Int(Rnd() * 49)) + 1
lblLottoBall3.Text = CStr(Int(Rnd() * 49)) + 1
Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
Randomize
|
|
|
|
|
Private Sub btnGenerate_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnGenerate.Click
lblLottoBall1.Text = CStr(Int(Rnd() * 49)) + 1
Do Until (lblLottoBall2.Text <> lblLottoBall1.Text)
lblLottoBall2.Text = CStr(Int(Rnd() * 49)) + 1
Loop
Do Until (lblLottoBall3.Text <> lblLottoBall1.Text And lblLottoBall3.Text <> lblLottoBall2.Text)
lblLottoBall3.Text = CStr(Int(Rnd() * 49)) + 1
Loop
End Sub
Like i said this is a bit inefficient, but on the other hand it looks like you're writing a windows app so timing shouldn't be a huge issue. Plus most of the time it won't have to regenerate a number anyway (only one time in 25 i think?) so you're gonna have very little overhead anyway, mainly just from the comparisons.
Regards,
Tristan Jones
|
|
|
|
|
Here is a neat way of doing it:
www.guffa.com : Random without duplicates[^]
The code is in VBScript, but you should easily be able to convert it. The code itself is not complicated, actually it's surprisingly simple. It's the theory behind the algorithm that is clever.
---
b { font-weight: normal; }
|
|
|
|
|
hi everybody, plz if any one could help me in this pb
i need to add a scrollbar to my form & i want to activate them, i mean that i want when i press on the horizontal scrollbar, my form start to move.
can anyone help me plz on this
i be very thankfull.
waelhawari
|
|
|
|
|
Well, it's possible, but a bit of a pain to handle, depending on what you're doing with them.
If all you're doing is putting a bunch of controls on the form and trying to move them around because the form is too small to show them, you're really wasting your time. All you need to do is drop a Panel control on the form, dock it so it takes up the entire surface of the form, set its AutoScroll property to True, then put all your controls on the panel. It takes care of moving everything around for you!
Dave Kreskowiak
Microsoft MVP - Visual Basic
|
|
|
|
|
Hi again
In fact, yes i need to put a lot of listbox control & the form is to small, so is there is anyway to do that.
i need help on this plz, it's so urgent.
10x a lot for replyin.
waelhawari
|
|
|
|
|
Hi again
In fact, yes i need to put a lot of listbox control & the form is to small, so is there is anyway to do that, i am using a visual basic 6 platform.
i need help on this plz, it's so urgent.
10x a lot for replyin.
waelhawari
|
|
|
|
|
VB6?? Yikes...
The only other usable container control, IIRC, is the PictureBox. There is no Panel control like there is in .NET.
If you have that many controls on the form, you REALLY need to rethink your UI. Break down what each part of this form does into smaller parts and dedicate them to their own forms.
I direct you to the Official Guidelines for User Interface Developers and Designers[^]. This describes the concepts behind a good user experience.
Dave Kreskowiak
Microsoft MVP - Visual Basic
|
|
|
|
|
Any way, it's ok 10x a lot for replyin..
i will use i pictureBox & i will put the Scrollbar on it.
10x a lot again
waelhawari
|
|
|
|
|
Hi all,
I'm currently trying to add (with a button) rows into tables (html table, asp table or gridView) .
I've tried : (asp:Table)
Private Sub AddRow()
Dim count As Integer = procTable.Rows.Count //never increment !!!
Dim myRow As New TableRow
Dim myCell As New TableCell
myCell.Text = "myCell"
myRow.Cells.Add(myCell)
'this is the asp:Table
procTable.Rows.AddAt(count, myRow)
End Sub
Had anyone an idea???
Thanks a lot
ElpenS
-- modified at 10:26 Tuesday 4th July, 2006
|
|
|
|
|