Focused row not working - Gridview - vb.net

I am using Dev Express to develop a form in which i have a GridControl with a View inside a View.
It looks like this:
I am then trying to use the event ValidatingEditor to validate the user input.
I tried to do that by doing:
Private Sub grvObsAM_Artigos_ValidatingEditor(ByVal sender As Object, ByVal e As DevExpress.XtraEditors.Controls.BaseContainerValidateEditorEventArgs) Handles grvObsAM_Artigos.ValidatingEditor
Dim row As Integer = Me.grvObsAM_Artigos.FocusedRowHandle
This, however always returns me something like -99999..
I poked around and tried this other solution using the sender from the event:
Private Sub grvObsAM_Artigos_ValidatingEditor(ByVal sender As Object, ByVal e As DevExpress.XtraEditors.Controls.BaseContainerValidateEditorEventArgs) Handles grvObsAM_Artigos.ValidatingEditor
Dim grv As DevExpress.XtraGrid.Views.Grid.GridView = CType(sender, DevExpress.XtraGrid.Views.Grid.GridView)
Dim row As Integer = grv.FocusedRowHandle
And using this second solution i managed to get the focused row handle. Even though this worked this time (because the event was triggered by the view itself and i had access to the sender) this doesn't solve my problem as there are other events where the sender is not the view and the problem persists.
Usign Me.grvObsAM_Artigos."insert anything here" doesn't seem to work properly.
Does anyone have any idea on why this is happening? Am i missing something?
Regards,

I think your issue is actually that you have several of the grvObsAM_Artigos gridviews. One for each row that has the details. So you need to use the view above ti to access the proper one. Using:
Dim grv as XtraGrid.Views.Grid.GridView = grvObsAM.GetDetailView(RowHandle, 0)
That should give you the right instance of the gridView you want. Everytime a master row is expanded and collapsed, the child is created and destroyed respectively.
This should give you a bit more background.
http://documentation.devexpress.com/#WindowsForms/DevExpressXtraGridViewsGridGridView_GetDetailViewtopic

Related

Add Textbox values in CheckedListBox( as items) using VB.net

i'm using vb.net to make a UI that connects via RS232. the 1st output that i defined is some kinda list of products, that i defined to be showed in a textbox.
Now i need to add items to that checkedlistbox. Don't mind the full list , think as it was only 1 product .
Example, textbox1.text="apple", so i want add the item "apple" to the listbox.
Private Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click
SerialPort1.Write("Products" & vbCr)
Dim separated = TextBox1.Text.Split(";")
CheckedListBox1.Items = separated.Text 'i know this is wrong :('
End Sub
i tried everything , but there's no similar question anywhere. and pls, tell me what i've done wrong in the post before downvote ! cumps
Items is readonly. You need to use Add or AddRange. Since you're creating an array already, change it to this.
Dim separated = TextBox1.Text.Split(";")
CheckedListBox1.Items.Clear()
CheckedListBox1.Items.AddRange(separated)

vb.net connects to database access

im really new to this language so this is so simple please answer
Me.InfoBindingSource.RemoveCurrent()
i only have id t on my delete button do i have to adsome codes? knows anyone?
i've searched some sites and it is the only code they say. i connected it and actually worked on add. but with delete it dont.
Do i need to move something.. like files?
i've tried everything this is my last hope. thanks for the answer :)
here is the whole code
Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click
Me.InfoBindingSource.RemoveCurrent()
End Sub
That RemoveCurrent method will mark the current row in the bound DataTable as Deleted. Just like when adding or editing rows though, you still have to call Update on your data adapter or table adapter to save that change back to the database.

How to get more than one parent control in form

Newbie here :)
In order to achieve a transparency-type effect for pictureboxcharacter1 on the background, I have set pictureboxbackground1 as its parent.
this works fine.
For the second picturebox (on the same form) I tried the same thing and set pictureboxbackground2 as its parent so it would look transparent over pictureboxbackground2. However when I debug the application pictureboxcharacter2 disappears and only pictureboxbackground2 is visible.
the code I have is:
Private Sub Form2_Load(sender As System.Object, e As System.EventArgs) Handles MyBase.Load
Me.pictureboxcharacter1.Parent = Me.pictureboxbackground1
Me.pictureboxcharacter2.Parent = Me.pictureboxbackground2
End Sub
Really strange: if I put pictureboxcharacter2 on pictureboxbackground1 in the designer tab, while debugging it shows up on picturebackground2 and transparent (like how I wanted it to be)??
Does anyone know what's going on at all?
Please I'm NEED any help I could get
Is pictureboxcharacter1 and pictureboxcharacter2 one over other ? If so try making the one be other's parent.
Have a play with bring to front option and see if that works.

How to get the value of a record from a datagrid on a double click event

Basically I have been researching for hours on end and cannot find the answer.
Im using Visual Studio 2012, SQL server, using Visual basic.
I want to transfer the value of record from a datagridtable after it is double clicked so that it will link to a page with the value of the previous values.
I have tried selectedrow ect but still cant get it to work, I have also looked into global variables to see if I could transfer it that way but sadly no luck as I need to be able to get the value.
This is what I currently have, it just displays the first record from the table.
Private Sub FlightDataGridView_CellDoubleClick(sender As Object, e As
DataGridViewCellEventArgs) Handles FlightDataGridView.CellDoubleClick
Dim SelectedRowView As Data.DataRowView
Dim SelectedRow As CompleteDataSet.FlightRow
SelectedRowView = CType(FlightBindingSource.Current, System.Data.DataRowView)
SelectedRow = CType(SelectedRowView.Row, CompleteDataSet.FlightRow)
Dim BookForm As New ViewFlights
BookForm.LoadBookForm(SelectedRow.Flight_ID)
BookForm.Show()
End Sub
In the load event for the 'ViewFlights' form I have this:
FlightBookingTableAdapter.FillByFlightID(CompleteDataSet.FlightBooking, Flight_ID:=)
However what goes after 'Flight_ID:='
Thanks for any help

Dynamic dropdown based on Radio selection

Good morning all! Myself and a co-worker are tasked with a system-wide scripting solution but neither of us are .NET programmers so we need your help.
We have a GUI that displays a radio selection box (3 options) that are the three sites where our hospitals are. We need to dropdown located on the form to fill with only the locations based on the selected radio option.
my gui http://web6.twitpic.com/img/40330741-85d91a5637f2445b322e62df17cf3351.4aef01c5-full.jpg
Here is the code behind we have so far (sorry, VB)
Public Class frmCEHLI
Private Sub Label1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Label1.Click
End Sub
Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
'TODO: This line of code loads data into the 'CELocDataSet.dbo_Locations' table. You can move, or remove it, as needed.
Me.Dbo_LocationsTableAdapter.Fill(Me.CELocDataSet.dbo_Locations)
End Sub
Private Sub btnSubmit_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnSubmit.Click
MsgBox("Submit button has been pressed")
End Sub
End Class
For the record the Location dropdown is currently databound but its a static SELECT statement which brings us all the locations but we'd prefer it to be cleaner if it only returned the locations based on Site. We are using Visual Basic 2008 Express Edition for development. Any help/code is appreciated, thanks!
Sorry not to respond back sooner, busy, and wanted to dig up a sample that did just what you were needing.
Create two comboboxes on your form. You can bind either fixed values, or from a table on the first combo. Then, from the property/events sheet, first set the "AutoPostBack" to TRUE, then on the events, click for the "SelectedIndexChanged" event to bring up some code.
The "Sender" object parameter will be the combobox itself, so you'll be able to analyse the property settings via debugging to find what key/value was chosen.
Then, run whatever query from your data querying control, business object, or whatever that gets your results, such as to a DataSet or DataTable.
Finally, set the datasource of your second combo to the above result query, set dataTextField and DataValueField and issue DataBind() to the combo.
That should get exactly what you need.
Then, when someone makes a selection from the second combo, you can have code within ITS "SelectedIndexChanged" event (also based on its AutoPostBack or actual submit button on the form).
Hope this helps.
I would create two combobox controls... One for the "where", then, on the InteractiveChange event by the user to post-back to the page using that answer for the second combobox of locations based on the "where" value of the first combo.