|
hi,
in vb.net i have a form which contains 2 buttons and some text fields. the user may enter the data in text fileds in the following format.
ex. "have a #nice# day". some of the words may be prefixed and suffixed with the # symbol. now when user presses the first button i want to store these data(dataset) to the rtf or text file.
when the user presses the 2nd button, i want to open the same text or rtf file and then i want to format the file in such a way that. all the #(hash) delimited words should be italisized and the file has to be save.
so anyone pls. help me.
thanks in advance
thiru.
|
|
|
|
|
Help you with what? So far, you haven't asked a question we can answer. You'll have to be specific about what part of your application you need help with and what the problem is.
RageInTheMachine9532
"...a pungent, ghastly, stinky piece of cheese!" -- The Roaming Gnome
|
|
|
|
|
I need code for two buttons. to save the tab delimited file in the file. and when i press the 2nd button to italisize the # delimited text in the file.
thank u,
thiru
|
|
|
|
|
Ok. There is nothing "tab delimited" about your initial post.
All your doing is saving the Text to a file. If your using a RichTextBox control, all you need is the .LoadFile and .SaveFile methods to do this for you.
The the second part, you have to scan the text to find the first occurance of a '#' character. Save that position. Continue scanning until you find the next '#". This will give you enough information to set the .SelectStart and .SelectLegth properties of the RichTextBox, then use the .SelectionFont property to change the font to italics. An example of which is found here[^] on MSDN.
Why does this smell like homework?
RageInTheMachine9532
"...a pungent, ghastly, stinky piece of cheese!" -- The Roaming Gnome
|
|
|
|
|
Is there a way, to get at the 'Main Bindable Property' of any given control. I am thinking, probably using system.reflection but i don't know how.
I have a bunch of different controls and i need to programmatically bind them to a dataset. To create a windows.forms.binder i need to know the property i want to bind to - the main bindable property for this particular control.
Help anyone?
Jan Engel Ketmig
|
|
|
|
|
JanEngelKetmig wrote:
'Main Bindable Property'
?????
Are you talking about the "default property"? Like Text for a TextBox?
I think you're looking for DefaultPropertyAttribute[^], which you should be able to find using Reflection. I don't have any example code, because frankly, I've never had to find/use the DefaultProperty for anything.
RageInTheMachine9532
"...a pungent, ghastly, stinky piece of cheese!" -- The Roaming Gnome
|
|
|
|
|
WOW that was fast... yes!, that oughtta do it... Thanks man..!
Jan Engel Ketmig
|
|
|
|
|
Hello there
I have one folder on C drive and I want to move it to any other logical drive D or E. I am using this code which gives me error that cannot move between logical drives.
Note: The Source Folder could have N Number of sub folders and files
System.IO.Directory.Move("C:\TestFolder", "D:\TestFolder")
I also tried this which gives me error that file not found....
Rename("C:\TestFolder", "D:\TestFolder")
Any Solution will be appreciated
Best Regards
Rizwan Bashir
|
|
|
|
|
Uhhhh.... The error message should make it obvious. You can't move between two drives/volumes/shares. You can, however, copy the source to the destination, then go back and delete the source. You can only move when the source and destination are on the same drive/volume/share.
This is spelled out in the documentation for Directory.Move , here[^] on MSDN. Look under Exceptions.
RageInTheMachine9532
"...a pungent, ghastly, stinky piece of cheese!" -- The Roaming Gnome
|
|
|
|
|
i work on database application with vb6
and i depend on data control in my program
from other side, i build my databse file with data manager
on vb6?
how can i protect .mdb file with password?
and how can i open it from vb6 in this case?
|
|
|
|
|
You can protect your Access database with a password all you want. But it can be broken and revealed so easily with off-the-shelf utlities that anyone can download from the web for FREE. Why waste your time?
RageInTheMachine9532
"...a pungent, ghastly, stinky piece of cheese!" -- The Roaming Gnome
|
|
|
|
|
what are others stratigies about security?
|
|
|
|
|
In an Access database? There are none. Access is meant as a desktop database, not a secure storage medium. The only other you can do is encrypt the sensitive data before it's sent to the datbase, but you won't be able to search on it.
RageInTheMachine9532
"...a pungent, ghastly, stinky piece of cheese!" -- The Roaming Gnome
|
|
|
|
|
|
Hi All
I want to buy a DHTML Edit control, which i can use in my VB.NET Windows Applivation. I dont want to use control provided by .NET itself. Can anybody please suggest me a nice control control for the same purpose.
Thanks
Sumit Domyan
|
|
|
|
|
Hi there! Can anyone help me with this: what dll's do i need in order to export a crystal report to text format during runtime.
When i run my program in visual basic 6, the exporting is done successfully. but when im using it in .exe, errors are generated.
i already used U2FTXT.DLL
what could be the problem?
pls help me.... thanks a lot!
|
|
|
|
|
I have a combo box on a windows form i'm using (in vstudio .NET 2003). It has to be a combo box, and I don't want the combobox to display the same text as what the selected value is. for example, i have four items in it now. when it drops down the user sees:
item 1
item 2
item 3
item 4
when the user clicks on item 1, instead of the box collapsing and displaying "item 1", i want it to display "this is a test". how do i do this? I've already tried comboBox3.Text = "this is a test" and putting it in the selectedIndexChanged, selectedValueChanged, Click, mouseUp, and textChanged events for the combobox, but it doesn't work. it still displays whatever i clicked. what's going wrong?
|
|
|
|
|
Hi,
If it may help you and i really understood what you mean, I think may be you need a Lable near your comboBox. Whenever a user clicks on one of the Items in cmb then your Lable will tell
i hate combo boxes wrote:
this is a test
I hope it helps.
Good Luck
Acheto
|
|
|
|
|
you will have to manually draw the ComboBox Items. Set the OwnerDraw property to OwnerDrawFixed then have a look at the ComboBox.DrawItem event.
Let me know if you need more help on this.
Cheers
Tom
|
|
|
|
|
well actually the combo box is already an owner drawn one. This is the problem, in my combo box, i set it to owner drawn so the first line of my combo box was bold and underlined - acting as a header. So basically since this first line is acting as a header I don't want the user to be able to select/display that value when they click on it. I had looked in to somehow disabling that first item, but no luck. so i figured i'd cheat and just change the text when they click on it to make it seem that it was disabled. here's my code for the box:
Friend WithEvents ComboBox3 As System.Windows.Forms.ComboBox<br />
Private selectControls() As String<br />
<br />
<br />
Private Sub initializeComboBox()<br />
Me.ComboBox3 = New ComboBox<br />
Me.ComboBox3.DrawMode = System.Windows.Forms.DrawMode.OwnerDrawFixed<br />
Me.ComboBox3.Location = New System.Drawing.Point(10, 20)<br />
Me.ComboBox3.Name = "ComboBox3"<br />
Me.ComboBox3.Size = New System.Drawing.Size(136, 21)<br />
Me.ComboBox3.DropDownWidth = 136<br />
Me.ComboBox3.TabIndex = 0<br />
Me.ComboBox3.DropDownStyle = ComboBoxStyle.DropDown<br />
Me.ComboBox3.Location = New System.Drawing.Point(120, 112)<br />
selectControls = New String() {"Serial Status", "10303 test", "bloop!"}<br />
ComboBox3.DataSource = selectControls<br />
Me.Controls.Add(Me.ComboBox3)<br />
End Sub<br />
<br />
Protected Sub ComboBox3_DrawItem(ByVal sender As Object, _<br />
ByVal e As System.Windows.Forms.DrawItemEventArgs) _<br />
Handles ComboBox3.DrawItem<br />
<br />
Dim size As Single<br />
Dim myFont As System.Drawing.Font<br />
Dim family As FontFamily<br />
<br />
Dim itemColor As New System.Drawing.Color<br />
Select Case e.Index<br />
Case 0<br />
size = 8.25<br />
<br />
itemColor = System.Drawing.Color.White<br />
family = FontFamily.GenericSansSerif<br />
myFont = New Font(family, size, FontStyle.Bold Or FontStyle.Underline)<br />
<br />
Case 1<br />
size = 8.25<br />
itemColor = System.Drawing.Color.White<br />
family = FontFamily.GenericSansSerif<br />
myFont = New Font(family, size, FontStyle.Regular)<br />
Case 2<br />
size = 8.25<br />
itemColor = System.Drawing.Color.Blue<br />
family = FontFamily.GenericSansSerif<br />
myFont = New Font(family, size, FontStyle.Regular)<br />
<br />
End Select<br />
<br />
e.DrawBackground()<br />
<br />
Dim rect = New Rectangle(1, 0, 134, 15)<br />
e.Graphics.FillRectangle(New SolidBrush(Color.Empty), _<br />
rect)<br />
<br />
If e.State = 769 Then<br />
<br />
If e.Index = 0 Then <br />
<br />
e.Graphics.FillRectangle(New SolidBrush(Color.White), _<br />
rect)<br />
<br />
e.Graphics.DrawString(selectControls(e.Index), myFont, System.Drawing.Brushes.Black, _<br />
New System.Drawing.PointF(2, e.Bounds.Top))<br />
<br />
Else<br />
<br />
e.Graphics.DrawString(selectControls(e.Index), myFont, System.Drawing.Brushes.White, _<br />
New System.Drawing.PointF(2, e.Bounds.Top))<br />
End If<br />
<br />
Else<br />
<br />
e.Graphics.DrawString(selectControls(e.Index), myFont, System.Drawing.Brushes.Black, _<br />
New System.Drawing.PointF(2, e.Bounds.Top))<br />
<br />
<br />
End If<br />
e.DrawFocusRectangle()<br />
<br />
End Sub
I'm not too familiar with owner drawn stuff, I can do little stuff like this but real complex stuff i haven't had experience with yet. is there any way to tell it in here to display a different value for the item when it's clicked?
|
|
|
|
|
I am trying to create an autocomplete combobox for a datagrid in vb.net.
I have everything working, except that I cannot force the column to stop when a user presses TAB to enter the column.
I need to allow the user to press tab, and then my datagridcolumn must gain focus, but I cannot figure out how
Anyways, I've attached my code (It's based on some previous articles I have read).
I can get the control to retain focus when TAB is pressed if I put a break-point in the OnEnter(ByVal e as System.EventArgs)
of the NoKeyUpCombo Class, but not without that.
Please help!!!!
Jake
DataGridComboBoxColumn:
<br />
Option Strict Off<br />
Option Explicit On <br />
<br />
Imports Microsoft.VisualBasic<br />
Imports System<br />
Imports System.ComponentModel<br />
Imports System.Data<br />
Imports System.Data.Common<br />
Imports System.Data.OleDb<br />
Imports System.Drawing<br />
Imports System.Windows.Forms<br />
<br />
Namespace DataGridTextBoxCombo<br />
' Step 1. Derive a custom column style from DataGridTextBoxColumn<br />
' a) add a ComboBox member<br />
' b) track when the combobox has focus in Enter and Leave events<br />
' c) override Edit to allow the ComboBox to replace the TextBox<br />
' d) override Commit to save the changed data<br />
Public Class DataGridComboBoxColumn<br />
Inherits DataGridTextBoxColumn<br />
Public WithEvents ColumnComboBox As NoKeyUpCombo<br />
Private _source As System.Windows.Forms.CurrencyManager<br />
Private _rowNum As Integer<br />
Private _isEditing As Boolean<br />
Public Shared _RowCount As Integer<br />
<br />
<br />
Public Sub New()<br />
_source = Nothing<br />
_isEditing = False<br />
_RowCount = -1<br />
<br />
ColumnComboBox = New NoKeyUpCombo<br />
ColumnComboBox.DropDownStyle = ComboBoxStyle.DropDown<br />
<br />
AddHandler ColumnComboBox.SelectionChangeCommitted, AddressOf ComboStartEditing<br />
End Sub 'New<br />
<br />
Private Sub HandleScroll(ByVal sender As Object, ByVal e As EventArgs)<br />
If ColumnComboBox.Visible Then<br />
ColumnComboBox.Hide()<br />
End If<br />
End Sub 'HandleScroll<br />
<br />
Private Sub ComboStartEditing(ByVal sender As Object, ByVal e As EventArgs)<br />
_isEditing = True<br />
MyBase.ColumnStartedEditing(sender)<br />
End Sub 'ComboMadeCurrent<br />
<br />
<br />
Private Sub CompletionCombo_Leave(ByVal sender As Object, ByVal e As System.EventArgs) Handles ColumnComboBox.Leave<br />
If _isEditing Or ColumnComboBox._isEditing Then<br />
SetColumnValueAtRow(_source, _rowNum, ColumnComboBox.Text)<br />
_isEditing = False<br />
Invalidate()<br />
<br />
End If<br />
ColumnComboBox.Hide()<br />
AddHandler Me.DataGridTableStyle.DataGrid.Scroll, New EventHandler(AddressOf HandleScroll)<br />
End Sub 'LeaveComboBox<br />
<br />
<br />
Protected Overloads Overrides Sub Edit(ByVal [source] As System.Windows.Forms.CurrencyManager, ByVal rowNum As Integer, ByVal bounds As System.Drawing.Rectangle, ByVal [readOnly] As Boolean, ByVal instantText As String, ByVal cellIsVisible As Boolean)<br />
<br />
MyBase.Edit([source], rowNum, bounds, [readOnly], instantText, cellIsVisible)<br />
<br />
'_isEditing = True<br />
_rowNum = rowNum<br />
_source = [source]<br />
<br />
ColumnComboBox.Parent = Me.TextBox.Parent<br />
ColumnComboBox.Location = Me.TextBox.Location<br />
ColumnComboBox.Size = New Size(Me.TextBox.Size.Width, ColumnComboBox.Size.Height)<br />
'ColumnComboBox.SelectedIndex = ColumnComboBox.FindStringExact(Me.TextBox.Text)<br />
ColumnComboBox.Text = Me.TextBox.Text<br />
Me.TextBox.Visible = False<br />
ColumnComboBox.Visible = True<br />
AddHandler Me.DataGridTableStyle.DataGrid.Scroll, AddressOf HandleScroll<br />
<br />
ColumnComboBox.BringToFront()<br />
ColumnComboBox.Focus()<br />
End Sub 'Edit<br />
<br />
<br />
Protected Overrides Function Commit(ByVal dataSource As System.Windows.Forms.CurrencyManager, ByVal rowNum As Integer) As Boolean<br />
<br />
If _isEditing Then<br />
_isEditing = False<br />
SetColumnValueAtRow(dataSource, rowNum, ColumnComboBox.Text)<br />
End If<br />
Return True<br />
End Function 'Commit<br />
<br />
<br />
Protected Overrides Sub ConcedeFocus()<br />
Console.WriteLine("ConcedeFocus")<br />
MyBase.ConcedeFocus()<br />
End Sub 'ConcedeFocus<br />
<br />
Protected Overrides Function GetColumnValueAtRow(ByVal [source] As System.Windows.Forms.CurrencyManager, ByVal rowNum As Integer) As Object<br />
<br />
Dim s As Object = MyBase.GetColumnValueAtRow([source], rowNum)<br />
Dim dv As DataView = CType(Me.ColumnComboBox.DataSource, DataView)<br />
Dim rowCount As Integer = dv.Count<br />
Dim i As Integer = 0<br />
Dim s1 As Object<br />
<br />
'if things are slow, you could order your dataview<br />
'& use binary search instead of this linear one<br />
While i < rowCount<br />
s1 = dv(i)(Me.ColumnComboBox.ValueMember)<br />
If (Not s1 Is DBNull.Value) AndAlso _<br />
(Not s Is DBNull.Value) AndAlso _<br />
s = s1 Then<br />
Exit While<br />
End If<br />
i = i + 1<br />
End While<br />
<br />
If i < rowCount Then<br />
Return dv(i)(Me.ColumnComboBox.DisplayMember)<br />
End If<br />
Return DBNull.Value<br />
End Function 'GetColumnValueAtRow<br />
<br />
<br />
Protected Overrides Sub SetColumnValueAtRow(ByVal [source] As System.Windows.Forms.CurrencyManager, ByVal rowNum As Integer, ByVal value As Object)<br />
Dim s As Object = value<br />
<br />
Dim dv As DataView = CType(Me.ColumnComboBox.DataSource, DataView)<br />
Dim rowCount As Integer = dv.Count<br />
Dim i As Integer = 0<br />
Dim s1 As Object<br />
<br />
'if things are slow, you could order your dataview<br />
'& use binary search instead of this linear one<br />
While i < rowCount<br />
s1 = dv(i)(Me.ColumnComboBox.DisplayMember)<br />
If (Not s1 Is DBNull.Value) AndAlso _<br />
s = s1 Then<br />
Exit While<br />
End If<br />
i = i + 1<br />
End While<br />
If i < rowCount Then<br />
s = dv(i)(Me.ColumnComboBox.ValueMember)<br />
Else<br />
s = DBNull.Value<br />
End If<br />
MyBase.SetColumnValueAtRow([source], rowNum, s)<br />
End Sub 'SetColumnValueAtRow <br />
<br />
End Class 'DataGridComboBoxColumn<br />
<br />
<br />
End Namespace<br />
NoKeyUpCombo.vb:
<br />
Option Strict Off<br />
Option Explicit On <br />
<br />
Imports Microsoft.VisualBasic<br />
Imports System<br />
Imports System.ComponentModel<br />
Imports System.Data<br />
Imports System.Data.Common<br />
Imports System.Data.OleDb<br />
Imports System.Drawing<br />
Imports System.Windows.Forms<br />
<br />
Namespace DataGridTextBoxCombo<br />
Public Class NoKeyUpCombo<br />
Inherits ComboBox<br />
Private WM_KEYUP As Integer = &H101<br />
Public _isEditing As Boolean = False<br />
<br />
Protected Overrides Sub WndProc(ByRef m As System.Windows.Forms.Message)<br />
If m.Msg = WM_KEYUP Then<br />
'ignore keyup to avoid problem with tabbing & dropdownlist;<br />
Return<br />
End If<br />
MyBase.WndProc(m)<br />
End Sub 'WndProc<br />
<br />
Protected Overrides Sub OnEnter(ByVal e As System.EventArgs)<br />
_isEditing = True<br />
MyBase.Focus()<br />
End Sub<br />
<br />
Private Sub CompletionCombo_KeyUp(ByVal sender As Object, ByVal e As System.Windows.Forms.KeyEventArgs) Handles MyBase.KeyUp<br />
Dim sTypedText As String<br />
Dim iFoundIndex As Integer<br />
Dim oFoundItem As Object<br />
Dim sFoundText As String<br />
Dim sAppendText As String<br />
<br />
If Me.Items.Count > 0 Then<br />
'Allow select keys without Autocompleting<br />
Select Case e.KeyCode<br />
Case Keys.Back, Keys.Left, Keys.Right, Keys.Up, Keys.Delete, Keys.Down, Keys.ControlKey, Keys.ShiftKey, Keys.Alt, Keys.ShiftKey, Keys.MButton, Keys.LButton, Keys.RButton, Keys.Home, Keys.End<br />
'e.Handled = False<br />
Exit Sub<br />
End Select<br />
<br />
'Get the Typed Text and Find it in the list<br />
If Me.Text.Length > 0 And Me.Text.Length <> Me.SelectedText.Length Then<br />
sTypedText = Me.Text<br />
iFoundIndex = Me.FindString(sTypedText)<br />
<br />
'If we found the Typed Text in the list then Autocomplete<br />
If iFoundIndex >= 0 Then<br />
'Get the Item from the list (Return Type depends if Datasource was bound <br />
' or List Created)<br />
oFoundItem = Me.Items(iFoundIndex)<br />
<br />
'Use the ListControl.GetItemText to resolve the Name in case the Combo <br />
' was Data bound<br />
sFoundText = Me.GetItemText(oFoundItem)<br />
<br />
'Append then found text to the typed text to preserve case<br />
sAppendText = sFoundText.Substring(sTypedText.Length)<br />
Me.Text = sTypedText & sAppendText<br />
<br />
'Select the Appended Text<br />
Me.SelectionStart = sTypedText.Length<br />
Me.SelectionLength = sAppendText.Length<br />
'Me.SelectedIndex = iFoundIndex<br />
End If<br />
End If<br />
End If<br />
<br />
End Sub<br />
<br />
Private Sub CompletionCombo_Leave(ByVal sender As Object, ByVal e As System.EventArgs) Handles MyBase.Leave<br />
Dim iFoundIndex As Integer<br />
<br />
If Me.Items.Count > 0 Then<br />
Dim sFoundText As String = ""<br />
If Me.SelectedText.Length <> Me.Text.Length Then<br />
sFoundText = Me.Text.Substring(Me.SelectedText.Length, Me.Text.Length)<br />
End If<br />
If sFoundText.Length > 0 Then<br />
iFoundIndex = Me.FindString(Me.Text)<br />
<br />
Me.SelectedIndex = iFoundIndex<br />
End If<br />
End If<br />
<br />
' Now ask to make a new address, if there is no autocomplete.<br />
If MyBase.SelectedIndex = -1 And MyBase.Text.Length > 0 Then<br />
If MessageBox.Show("Cannot find item: '" & MyBase.Text & "'." & vbCrLf & "Would you like to create a new item?", "Create a New Entry?", MessageBoxButtons.YesNo, MessageBoxIcon.Question) = DialogResult.Yes Then<br />
' TODO: Add code to make a new inventory item.<br />
Else<br />
MyBase.Text = ""<br />
MyBase.Focus()<br />
End If<br />
End If<br />
End Sub<br />
End Class 'NoKeyUpCombo<br />
End Namespace<br />
<br />
|
|
|
|
|
Create a class module and stick this code in it:
Imports System
Imports System.Data
Imports System.Windows.Forms
Imports System.Drawing
Namespace ComboBoxCode
Public Class DataGridComboBoxColumn
Inherits DataGridTextBoxColumn
Private _comboBox As DataGridComboBox
Private _sorce As CurrencyManager
Private _rowNumber As Integer
Private _editing As Boolean
Public Sub New(ByVal dataSource As DataView, _
ByVal displayMember As String, _
ByVal valueMember As String)
_sorce = Nothing
_editing = False
_comboBox = New DataGridComboBox
_comboBox.DropDownStyle = ComboBoxStyle.DropDownList
_comboBox.Visible = False
_comboBox.DataSource = dataSource
_comboBox.DisplayMember = displayMember
_comboBox.ValueMember = valueMember
AddHandler _comboBox.Leave, AddressOf _comboBox_Leave
AddHandler _comboBox.SelectionChangeCommitted, _
AddressOf _comboBox_SelectionChangeCommitted
End Sub
Public ReadOnly Property ComboBox() As DataGridComboBox
Get
Return _comboBox
End Get
End Property
Private Sub _comboBox_Leave(ByVal sender As Object, _
ByVal e As EventArgs)
If _editing Then
_editing = False
SetColumnValueAtRow(_sorce, _rowNumber, _
_comboBox.Text)
Invalidate()
End If
_comboBox.Visible = False
AddHandler DataGridTableStyle.DataGrid.Scroll, _
AddressOf DataGrid_Scroll
End Sub
Private Sub DataGrid_Scroll(ByVal sender As Object, _
ByVal e As EventArgs)
If _comboBox.Visible Then
_comboBox.Visible = False
End If
End Sub
Private Sub _comboBox_SelectionChangeCommitted( _
ByVal sender As Object, ByVal e As EventArgs)
_editing = True
MyBase.ColumnStartedEditing(CType(sender, Control))
End Sub
Protected Overrides Function GetMinimumHeight() As Integer
Return _comboBox.PreferredHeight
End Function
Protected Overrides Sub SetDataGridInColumn( _
ByVal value As DataGrid)
MyBase.SetDataGridInColumn(value)
_comboBox.Parent = CType(value, Control)
End Sub
Protected Overrides Sub ConcedeFocus()
MyBase.ConcedeFocus()
_comboBox.Visible = False
End Sub
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)
MyBase.Edit(source, rowNum, bounds, [readOnly], _
instantText, cellIsVisible)
Me.TextBox.Visible = False
_rowNumber = rowNum
_sorce = source
_comboBox.Bounds = bounds
_comboBox.RightToLeft = _
Me.DataGridTableStyle.DataGrid.RightToLeft
If cellIsVisible AndAlso Not [readOnly] Then
_comboBox.Visible = True
_comboBox.BringToFront()
_comboBox.Focus()
End If
_comboBox.SelectedIndex = _
_comboBox.FindStringExact(Me.TextBox.Text)
AddHandler DataGridTableStyle.DataGrid.Scroll, _
AddressOf DataGrid_Scroll
End Sub
Protected Overrides Function Commit( _
ByVal dataSource As CurrencyManager, _
ByVal rowNum As Integer) As Boolean
If _editing Then
_editing = False
SetColumnValueAtRow(dataSource, rowNum, _
_comboBox.Text)
End If
Return True
End Function
Protected Overrides Sub SetColumnValueAtRow( _
ByVal source As CurrencyManager, _
ByVal rowNum As Integer, ByVal value As Object)
MyBase.SetColumnValueAtRow(source, rowNum, _
_comboBox.FindValueMember(value))
End Sub
Protected Overrides Function GetColumnValueAtRow( _
ByVal source As CurrencyManager, _
ByVal rowNum As Integer) As Object
Dim val As Object = _
MyBase.GetColumnValueAtRow(source, rowNum)
Return _comboBox.FindDisplayMember(val)
End Function
End Class
Public Class DataGridComboBox
Inherits System.Windows.Forms.ComboBox
Private WM_KEYUP As Integer = &H101
Protected Overrides Sub WndProc( _
ByRef theMessage As System.Windows.Forms.Message)
If theMessage.Msg = WM_KEYUP Then
Return
End If
MyBase.WndProc(theMessage)
End Sub
Public Function FindValueMember( _
ByVal display As Object) As Object
Dim dv As DataView = CType(DataSource, DataView)
Dim rowCount As Integer = dv.Count
Dim disp As Object
Dim i As Integer
For i = 0 To rowCount - 1
disp = dv(i)(DisplayMember)
If display.Equals(disp) Then
Return dv(i)(ValueMember)
End If
Next i
Return display
End Function
Public Function FindDisplayMember( _
ByVal value As Object) As Object
Dim dv As DataView = CType(DataSource, DataView)
Dim rowCount As Integer = dv.Count
Dim val As Object
Dim i As Integer
For i = 0 To rowCount - 1
val = dv(i)(ValueMember)
If value.Equals(val) Then
Return dv(i)(DisplayMember)
End If
Next i
Return DBNull.Value
End Function
End Class
End Namespace
Then go to where you format your datagrid and use this code for the column you need a datagrid combo box for:
Dim grdColStyle4 As New ComboBoxCode.DataGridComboBoxColumn( _
dvgProducts, "ProductCode", "ProductCode")
''''DataSource, DisplayMember, ValueMember
With grdColStyle4
.MappingName = "ProductCode"
.HeaderText = "Product ID"
.NullText = ""
.Width = 80
End With
You will have to create either a dataview or dataset for your datasource, but this should get you where you want to be.
Let me know how this works out for you.
|
|
|
|
|
Hello everybody,
Trying to develope a small Visual Basic.Net project, I am stucked on one point.
I have a 2.Dimensional Array filling a DataTable. Now I want to build a Diagramm, I don’t want to use an Excel. But every effort to do that doesn’t work.
Here is an example of an Array with the Result of some kind of Formula:
Dim Result(2, 3) As String
For x = 0 To 2
For y = 0 To 3
Result(x, y) = ((x + y) * (y) - x)
Next
Next
Now the Question is kann somebody show me how to build a Diagramm with a Diagramm Scale of (X, Y) using BitMap or Grafics?
Thanx in Advance & Regards
Mickael
|
|
|
|
|
When a user logs in to my web app, I save their login id as Public Shared so that I can reference it later.
Sometimes when it is referenced later, it will grab the login id from someone else's session who is also running the app.
I tried saving the login id as Session("loginid"), it works ok for a while, then it loses it and goes to null.
No messages are coming up saying that the session has been lost, any ideas on what could be wrong or how to fix this would help out a lot.
Thank You!
|
|
|
|
|
partt wrote:
I save their login id as Public Shared
partt wrote:
when it is referenced later, it will grab the login id from someone else's session
That is the correct behaviour - Public Shared mean that all instances of the class will share the same value so it should not be used for storing individual user IDs as a web application is a multi-user system and lots of users will be using it at the same time.
partt wrote:
Session("loginid"), it works ok for a while, then it loses it and goes to null
That is most likely because the session has timed out. There is a setting in the web.config to make the session longer if you need to. The default is 20 minutes, so if the user does not interact with the web application for 20 minutes their session will end so that the server can free up resources to deal with users that are actually using the system. At this point the timed-out user will need to log in again.
Does this help?
Do you want to know more?
WDevs.com - Open Source Code Hosting, Blogs, FTP, Mail and Forums
|
|
|
|
|