|
Thank you, your powers are awesome.
Programming is work, it isn't finger painting. Luc Pattyn
|
|
|
|
|
DevShock looks like it's dead. You'll have to find a replacement library if you don't want to write your own.
Something like IP*Works[^].
|
|
|
|
|
Hi guys I need your smart hands to handle this code
I have three columns on (Table1DataGridView) take names: (F/T) (Last name1) (Last name2)
first column takes Bit value ( Checkedbox. true or false ) the rest of columns takes text value type.
I wonder how can I do something like this : if F/T is checked true then Last name1 equuleus the value of Last name2
I try this
Private Sub Table1DataGridView_CellContentClick(ByVal sender As System.Object, ByVal e As System.Windows.Forms.DataGridViewCellEventArgs) Handles Table1DataGridView.CellContentClick
If Table1DataGridView.Rows(0).Cells(0).Value.chcked =True Then
Table1DataGridView.Rows(0).Cells(1).Value=Table1DataGridView.Rows(0).Cells(2).Value
End if
End sub
then I thought I should know what is the name of F/T column and using that name to give that name my code which is las name1 = last name2
and I did this, I went to ( Edit columns option and then I copy the name of F/T column, and the Name of las nmae1,and the Name of las nmae2 ) and I did this code but I got nothing
If DataGridViewCheckBoxColumn1.TrueValue Then
DataGridViewTextBoxColumn2 = DataGridViewTextBoxColumn3
End If
I'm not sure if can did this or it's not possible, Please if you could give hand with this I will be appreciated
thanks
|
|
|
|
|
I'm not sure I understand what you are trying to achieve here or maybe it's because here in Australia it's a Monday morning, and I'm still in weekend mode.
Why would you need the contents of Column 1 to be replaced with the contents of Column 2 if the value of Column 0 is checked?
Can you possibly provide some more information on what you trying to do.
|
|
|
|
|
yes that what I need
the contents of Column 1 to be replaced with the contents of Column 2.
or on other words because I'm in USA 9:33 pm cool night and cool weather
I need to move or copy what in cell to another cell that basically what I need once Column 0 is checked true. because Column 1 will be used as Query in my project.
what I gave was just example.
I'm focus now how do this to do something else but i'm not sure if some one did like this before or if it's possible to do.
thanks
|
|
|
|
|
If what you want is change how a column looks (as opposed to what it actually contains), then you could handle the CellFormatting event and perform any calculation and formatting you fancy right there.
|
|
|
|
|
no I need to move text from cell to another cell on the same row once column 0 is checked 
|
|
|
|
|
I have no idea what your problem could be, just handle the appropriate event.
MSDN doc on DataGridViewCheckBoxCell class says:
Typically, check box cell values are intended either for storage, like any other data, or for performing bulk operations. If you want to respond immediately when users click a check box cell, you can handle the DataGridView..::.CellClick event, but this event occurs before the cell value is updated. If you need the new value at the time of the click, one option is to calculate what the expected value will be based on the current value. Another approach is to commit the change immediately, and handle the DataGridView..::.CellValueChanged event to respond to it. To commit the change when the cell is clicked, you must handle the DataGridView..::.CurrentCellDirtyStateChanged event. In the handler, if the current cell is a check box cell, call the DataGridView..::.CommitEdit method and pass in the Commit value.
|
|
|
|
|
What Luc is suggesting is correct, use an event handler for the DataGridView to trigger the action you want to occur.
Is the DataGridView populated by a data table or array? Do you wish to save the changes back to the database?
But to just populate the second cell with the third cell's contents just use something like this.
'Declare a couple of variables to hold the row number and contents of the third cell
Dim pRowNo as Integer
Dim pstrContents as String
'Get the ROW number
pRowNo = Val(DataGridView.SelectedCells(0).RowIndex.ToString())
'It's here where you test if Cell 0 is checked, then if so the remainder (below) is actioned.
'Store contents of cell three
pstrContents = DataGridView.Rows(pRowNo ).Cells(2).Value
'Insert contents into cell two
DataGridView.Rows(gintROWNO).Cells(1).Value = pstrContents
(The above can be shortened, but I did it this way so you can step through to check the value being copied to "pstrContents" prior to the insert into the second cell)
It would be here you save any changes back to the data source and refresh the grid.
Does this help?
|
|
|
|
|
ok but under where I should put this code. you said
use an event handler, I'm sorry I don't how to use this feature where I can find the event handler is it something like this
Private Sub Button1_TextChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.TextChanged
End Sub
|
|
|
|
|
Hi romo22,
An event handler is just an event that is called when a user clicks on or otherwise actions a control, such as your DataGridView.
Clicking on the DataGridView, will trigger the On_Click event. The first line of code after the declaration gets the ROW number of the grid, which in turn is used to access the data from the cells. For example......
Private Sub DataGridView_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles DataGridView.Click
'Declare a couple of variables to hold the row number and contents of the third cell
Dim pRowNo as Integer
Dim pstrContents as String
'Get the ROW number
pRowNo = Val(DataGridView.SelectedCells(0).RowIndex.ToString())
'It's here where you test if Cell 0 is checked, then if so the remainder (below) is actioned.
'Store contents of cell three
pstrContents = DataGridView.Rows(pRowNo ).Cells(2).Value
'Insert contents into cell two
DataGridView.Rows(gintROWNO).Cells(1).Value = pstrContents
End Sub
This should get you started, you will find some great examples using Google.
Remember, this will place the data in the cell but will not save ot to your data source.
|
|
|
|
|
yes it's work as super but I wonder how can make cell 1 clear once checked is false where I can add the if and else function. I will try by myself first
thanks so much I spent six hours trying with myself finally I'm done with it oh my God
Private Sub Table1DataGridView_CellContentClick(ByVal sender As System.Object, ByVal e As System.Windows.Forms.DataGridViewCellEventArgs) Handles Table1DataGridView.CellContentClick
Dim pRowNo As Integer
Dim pstrContents As String
pRowNo = Val(Table1DataGridView.SelectedCells(0).RowIndex.ToString())
pstrContents = Table1DataGridView.Rows(pRowNo).Cells(2).Value
Table1DataGridView.Rows(pRowNo).Cells(1).Value = pstrContents
End Sub
|
|
|
|
|
Hi JohnPayton
I tried to add if function but it doesn't work with me the code without if function work prefect
Private Sub Table1DataGridView_CellContentClick(ByVal sender As System.Object, ByVal e As System.Windows.Forms.DataGridViewCellEventArgs) Handles Table1DataGridView.CellContentClick
Dim pRowNo As Integer
Dim pstrContents As String
pRowNo = Val(Table1DataGridView.SelectedCells(0).RowIndex.ToString())
If Table1DataGridView.Rows(pRowNo).Cells(0).Value = True Then
pstrContents = Table1DataGridView.Rows(pRowNo).Cells(2).Value
Table1DataGridView.Rows(pRowNo).Cells(1).Value = pstrContents
Else
Table1DataGridView.Rows(pRowNo).Cells(1).Value = ""
End If
End Sub
I need to add if because once cell 0 checked= false then cell1 = clear or "" empty
could please help me with this
modified 14-May-12 4:30am.
|
|
|
|
|
Payton I still need your help where I can add if function
|
|
|
|
|
Morning romo22,
Let me understand what you are doing here....
The way I read your code at the moment is If a user clicks on a Row and Cell 0 (checkbox) is Checked, then the contents of Cell 2 are moved into Cell 1 otherwise you clear the contents of Cell 1
Are you using mouse clicks to Check and UnCheck the checkbox in Cell 0 or is it being populated by a data source?
|
|
|
|
|
"The way I read your code at the moment is If a user clicks on a Row and Cell 0 (checkbox) is Checked, then the contents of Cell 2 are moved into Cell 1 otherwise you clear the contents of Cell 1"
yes that what I want to do
" Are you using mouse clicks to Check and UnCheck the checkbox in Cell 0 or is it being populated by a data source?"
yes I use the mouse clicks to Check and UnCheck the checkbox in Cell 0
|
|
|
|
|
I loaded the code below and it works, it's a little simplistic however by playing around with it I'm sure you can improve your skills by making adjustments.
Private Sub DataGridView1_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles DataGridView1.Click
Dim pRowNo As Integer
pRowNo = Val(DataGridView1.SelectedCells(0).RowIndex.ToString())
If DataGridView1.Rows(pRowNo).Cells(0).Value = 1 Then
DataGridView1.Rows(pRowNo).Cells(1).Value = DataGridView1.Rows(pRowNo).Cells(2).Value
Else
DataGridView1.Rows(pRowNo).Cells(1).Value = ""
End If
End Sub
|
|
|
|
|
Hi John thank you for standing with me in this code
I got this error
" Operator '=' is not defined for type 'DBNull' and type 'Integer'."
DataGridView1.Rows(pRowNo).Cells(0).Value = 1
I tried to do something like this
DataGridView1.Rows(pRowNo).Cells(0).Value.Tobit = 1
but I still get the same error notice that I'm working on Visual basic Studio 2010 is ther any difference 
|
|
|
|
|
You just have to test if the value is a null first. Using a IsDBNull function call.
http://www.freevbcode.com/ShowCode.asp?ID=5810
or
http://msdn.microsoft.com/en-us/library/tckcces5%28v=vs.71%29.aspx
|
|
|
|
|
|
Please check this link.
It is a tool allow you to convert between C# and VB.Net
Link
|
|
|
|
|
actually how to write this code correctly???
other txtsms not showing..just txtsms.text = seat booked
it just show Seat booked: seat1
only seat 1 show instead of 4 seats..plss help..
For i = 4 To wc
TxtSMS.Text = "Congratulation!! Your ticket succesfully booked. Detail of your tickect:" & vbCrLf & "Cinema: " & Branch & vbCrLf & "Movie title: " & moviename & vbCrLf & "Time: " & timeplaying & vbCrLf
TxtSMS.Text = "Tickect ID: " & randomID & "Pls show your tickect ID to our reception counter to get your tickect. TQ"
TxtSMS.Text = "Seat Booked: " & SplitWord(i).ToString & " "
Next
|
|
|
|
|
You do know that every time you set the value of the Text property it REPLACES the text that is already there, not appends to it, correct?
|
|
|
|
|
ooowwhh.. so how i could write the code to show that all .. actually i know i can use & vbcrlf & "something" something like that...
but my problem is i dont know how to display as this line as you can see on my code before:
"Seat booked: " & splitword(i).tostring
where i = 1 ,2 ,3 and until some number depends on the word count.
for know i only can show only for splitword(1).
i use txtsms.text = txtsms.text & "seat booked: " & splitword(i) but the text "seat booked" also repeated.. so what is the correct code to write?? 
|
|
|
|
|
Someone else gave you the answer. But, the underlying problem still remains. The problem you ran into a a copmlete lack of experience and very basic knowledge of VB.NET (or any other language). I seriously recommend picking up a beginners book on VB.NET and working through it.
|
|
|
|