PDA

View Full Version : آیا در دات نت چیزی مثل DriveListBox و DirListBox و FileListBox در VB6 داریم؟



niloufar
یک شنبه 22 مرداد 1385, 20:11 عصر
سلام
سوال که معلومه. البته اول تذکر بدم که منظورم Dialog ها نیست چون میخوام خودم کنترل هایی مثل اونا بسازم.
ممنون

zarrin_306
دوشنبه 23 مرداد 1385, 09:37 صبح
The Visual Basic 6.0 DriveListBox control was typically used to select or change drives in a File Open or Save dialog box. Visual Basic .NET has no equivalent for the DriveListBox control; however, the Windows Forms OpenFileDialog and SaveFileDialog controls provide the ability to create standard Windows dialog boxes for working with files.
During upgrade, any existing DriveListBox controls are upgraded to the VB6.DriveListBox control that is provided as a part of the compatibility library


The Windows Forms OpenFileDialog component is a pre-configured dialog box. It is the same Open File dialog box exposed by the Windows operating system. It inherits from the CommonDialog class.
Use this component within your Windows application as a simple solution for file selection in lieu of configuring your own dialog box. By relying on standard Windows dialog boxes, you create applications whose basic functionality is immediately familiar to users. Be aware, however, that when using the OpenFileDialog component, you must write your own file-opening logic.
Use the ShowDialog method to display the dialog at run time. You can enable users to multi-select files to be opened with the Multiselect property. Additionally, you can use the ShowReadOnly property to determine if a read-only check box appears in the dialog box. The ReadOnlyChecked property indicates whether the read-only check box is selected. Finally, the Filter property sets the current file name filter string, which determines the choices that appear in the "Files of type" box in the dialog box.
When it is added to a form, the OpenFileDialog component appears in the tray at the bottom of the Windows Forms Designer.

zarrin_306
دوشنبه 23 مرداد 1385, 09:44 صبح
[Visual Basic] The following example creates an OpenFileDialog, sets several properties, and displays the dialog box using the CommonDialog.ShowDialog method. The example assumes a form with a Button placed on it and the System.IO namespace added to it.

[Visual Basic.net]


Protected Sub button1_Click(sender As Object, e As System.EventArgs)
Dim myStream As Stream
Dim openFileDialog1 As New OpenFileDialog()

openFileDialog1.InitialDirectory = "c:\"
openFileDialog1.Filter = "txt files (*.txt)|*.txt|All files (*.*)|*.*"
openFileDialog1.FilterIndex = 2
openFileDialog1.RestoreDirectory = True

If openFileDialog1.ShowDialog() = DialogResult.OK Then
myStream = openFileDialog1.OpenFile()
If Not (myStream Is Nothing) Then
' Insert code to read the stream here.
myStream.Close()
End If
End If
End Sub

zarrin_306
دوشنبه 23 مرداد 1385, 09:49 صبح
[Visual Basic]The following example illustrates creating a SaveFileDialog, setting members, calling the dialog box using the ShowDialog method, and opening the selected file. The example assumes a form with a button placed on it.[Visual Basic.net]



Protected Sub button1_Click(sender As Object, e As System.EventArgs)
Dim myStream As Stream
Dim saveFileDialog1 As New SaveFileDialog()

saveFileDialog1.Filter = "txt files (*.txt)|*.txt|All files (*.*)|*.*"
saveFileDialog1.FilterIndex = 2
saveFileDialog1.RestoreDirectory = True

If saveFileDialog1.ShowDialog() = DialogResult.OK Then
myStream = saveFileDialog1.OpenFile()
If Not (myStream Is Nothing) Then
' Code to write the stream goes here.
myStream.Close()
End If
End If
End Sub

zarrin_306
دوشنبه 23 مرداد 1385, 09:55 صبح
جهت اطلا عات بیشتر به راهنمای مایکروسافت MSDN مراجعه شود

ghafoori
دوشنبه 23 مرداد 1385, 10:09 صبح
بله دوست عزیز تمام این کنترلها وجود دارند اما بطور پیش فرض داخل جعبه ابزار نیست برای این کار باید روی جعبه راست کلیک و گزینه choss new item را برگزینی بعد از تب .net ان سه کنترل است باید کنار انها تیک بزنی

niloufar
سه شنبه 24 مرداد 1385, 15:59 عصر
سلام
1- جناب zarrin_306 بنده که عرض کردم:


البته اول تذکر بدم که منظورم Dialog ها نیست چون میخوام خودم کنترل هایی مثل اونا بسازم


2- جناب ghafoori حق با شماست، من حواسم نبود که در لیست یه نگاهی بکنم!!

3- از هر دو بزرگوار ممنون

راستی اینا دقیقا کنترل های VB6 اند، آیا کنترل های قشنگ تری برای اینکار نداریم. مثلا اینکه یه جورایی بشه مثل FolderBrowser خود دات نت رو تولید کنیم، خیلی شیک تره :-)
البته بازم بگم


البته اول تذکر بدم که منظورم Dialog ها نیست چون میخوام خودم کنترل هایی مثل اونا بسازم

کسی نیاد خود همین کنترل FolderBrowser رو یا اون API لود کننده FolderBrowser رو معرفی کنه!!

niloufar
شنبه 28 مرداد 1385, 19:19 عصر
سلام
کسی برای شبیه سازی FolderBrowser نظری نداره؟