|
can i add textboxes only in the first cell of datagridview?
I have four rows in the datagriddview.
I am using the following code
Private Sub dg1_CellClick(ByVal sender As Object, ByVal e As System.Windows.Forms.DataGridViewCellEventArgs) Handles dg1.CellClick
If (e.ColumnIndex = 2) Then
TextBox1.Visible = True
TextBox1.Left = 42
TextBox1.Top = 19 * (Me.dg1.CurrentCell.RowIndex + 1)
TextBox1.Height = dg1.CurrentRow.Cells(0).Size.Height
TextBox1.Width = dg1.CurrentRow.Cells(0).Size.Width
End If
End Sub
as the row index increases , the coordinates flaws increases.
|
|
|
|
|
This doesn't place a textbox in the cell. It moves an existing textbox OVER a cell in the datagrid. The offset flaw increases as the textbox moves down because your probably off by one pixel in one side of the multiplication to set the Top value. Instead of 19, try multiplying the row height of the currently selected cell.
Though, why are you hovering a TextBox over a cell in a datagrid anyway?
|
|
|
|
|
Hi, I have a word template document and I need to programming in Access VBA code to create a new word document based on the template that i have. Suppose that my template is locate c:\mytemplate\MyTemplate.dot . I also need to write some value into the specific line of word document. If anyone have a sample code please let me know.
Thank in advance!
|
|
|
|
|
Can anyone tell me how to add a custom dll control at runtime? I can add the control at runtime but the control is not seen on the form. I can add the control at design time and everything works fine.
|
|
|
|
|
maybe you miss this...
me.Controls.Add(yourControl)
When you get mad...THINK twice that the only advice
Tamimi - Code
|
|
|
|
|
i am using dotnet 2003.i am doing my project in vb.net windows application.i have two form in my project.first form is datagrid .In second form label and textboxes are avilable to save the entering values in datagrid of first form through this 2nd form.my problem is,if i select the row or record and click edit menu means,want to display the values of that selected row in textboxes of second form.
for example,
in first form,
there are 4 columns named as name,age,rollno,address in datagrid.
values are ramu for namecolumn,24 for age column,42 for rollno column,cbe for address column.now values in datagrid like below
name age rollno address
ramu 24 42 cbe
in 2nd form,there are 4 label and 4 textbox.textbox arenamed as nametextbox,agetextbox,rollnotextbox,addresstextbox.
my problem is,
in first form,
if i select the row(ie.,ramu,24,42,cbe) and i click edit menu means,i want to display the values automatically (ramu in nametextbox,24 in agetextbox,42 in rollnotextbox,cbe in addresstextbox)in 2nd form.
during runtime in vb.net windows application.so how i automatically display the values of row in each textbox.plz help me.
|
|
|
|
|
hi sathyan,
use following code at click event of edit menu
form2.nametextbox= Grid1.CurrentRow.Cells(0).Value.ToString
form2.agetextbox= Grid1.CurrentRow.Cells(1).Value.ToString
form2.rollnotextbox= Grid1.CurrentRow.Cells(2).Value.ToString
form2.addresstextbox= Grid1.CurrentRow.Cells(3).Value.ToString
form2.show
hope this helps
Rupesh Kumar Swami
Software Engineer,
Integrated Solution,
Bikaner (India)
|
|
|
|
|
[img]http://i53.photobucket.com/albums/g56/marshmayllow/slidepuzzle.jpg[/img]
This' how the puzzle works. Quite sure everyone knows this game!
I'm a complete noob at this, and have not a slightest clue on how to start building the codes except that:
1. the buttons don't move (am i suppose to put the numbers under the 'text' property of the button?)
2. reseting it will give a new random arrangment
would be interested to know how to replace the numbers with images too..really thanks a million to whoever can help a poor soul here !
|
|
|
|
|
One has to ask why you're writing this, if you have no idea how to do it ? If it's homework, you should ask your teacher. If you're just trying to learn, I'd recommend trying something simpler first.
marshmayllow wrote: would be interested to know how to replace the numbers with images too
Buttons have an Image property.
Christian Graus - Microsoft MVP - C++
Metal Musings - Rex and my new metal blog
"I am working on a project that will convert a FORTRAN code to corresponding C++ code.I am not aware of FORTRAN syntax" ( spotted in the C++/CLI forum )
|
|
|
|
|
i want to create a gridview like editable custom control which may have combobox in one or more then one column .
at the time of specifing datasource to custom control it should fill data in Comboxes also.
mahendra
|
|
|
|
|
Hi,
I am using a ToolStrip that doesn't use the (default) DockStyle.Top setting because I set its AnchorStyles (to Top, Left and Right), by which the Dock property is overruled. The reason for this is that multiple Toolstrips need to be shown below each other.
The problem is that the Overflow button on the Toolstrip doesn't appear anymore when needed. When I dont set the AnchorStyles property, the Overflow button appears, but then the ToolStrips ignore the Location I give them and appear in the wrong order because they all have DockStyle.Top again.
Thanks.
Jim
|
|
|
|
|
Gday,
Ok first question....go easy
Im trying to make the text in a label change according to what is chosen in a combo box. I dont get why this doesnt change the text in the lblRate. Would appreciate any advice?
Private Sub cmbPlanes_SelectedIndexChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles cmbPlanes.SelectedIndexChanged<br />
<br />
Select Case Aircraft<br />
Case "Cessna 152"<br />
lblRate.Text = "$119"<br />
Case "Cessna 172"<br />
lblRate.Text = "$135"<br />
Case "Piper Cherokee"<br />
lblRate.Text = "$135"<br />
Case "Gazelle"<br />
lblRate.Text = "$85"<br />
Case "Gazelle"<br />
lblRate.Text = "$135"<br />
Case "Tecnam"<br />
lblRate.Text = "$110"<br />
Case "Beech Bonanza"<br />
lblRate.Text = "$289"<br />
Case Else<br />
lblRate.Text = "$0.00"<br />
End Select<br />
<br />
<br />
<br />
<br />
End Sub<br />
-- modified at 18:37 Saturday 2nd June, 2007
|
|
|
|
|
First guess - Aircraft is a variable that is not being changed. I suspect you want to set it from the cmbPlanes combo box.
Setting a breakpoint and stepping through would confirm if this is the case.
Christian Graus - Microsoft MVP - C++
Metal Musings - Rex and my new metal blog
"I am working on a project that will convert a FORTRAN code to corresponding C++ code.I am not aware of FORTRAN syntax" ( spotted in the C++/CLI forum )
|
|
|
|
|
Ok....Im showing my ignorance here but I dont get that.
what do you mean set it from the cmbPlanes combo box? If i use the drop down to choose an aircraft I want the lblRate text to change. (which Im sure you already knew) So are u saying that I dont need to declare this as a variable and instead just use cmbPlanes.Text? How do I link the variable named Aircraft to the chosen index in the combobox?
second....setting a breakpoint is beyond me at this stage..I have no idea how to do that.
Ouch!
|
|
|
|
|
idyot wrote: So are u saying that I dont need to declare this as a variable and instead just use cmbPlanes.Text?
In your case, yes.
Select Case cmbPlanes.Text
idyot wrote: How do I link the variable named Aircraft to the chosen index in the combobox
OK. To recant what I just said...If Airplane is a string varible, then all you do is something like this in your posted code:
Airplane = cmbPlanes.Text
Select Case Airplane
Case ....
This is really VB.NET 101 type stuff. I suggest picking up a book on VB.NET for beginners.
How you're doing this now isn't really the correct way of doing it in the first place. Normally, you'd have this data (and more) in a DataTable, or some other collection, and bind your controls to this data. Picking an item in the ComboBox would automatically select the rest of the records data.
I'm not really going to go into how this works because it's a more advanced technique. Something that will boggle your mind if you don't understand how Select/Case works yet.
Seriously, pick up a book or two.
|
|
|
|
|
Dave Kreskowiak wrote: This is really VB.NET 101 type stuff. I suggest picking up a book on VB.NET for beginners.
Yes its been discussed at length here over the past day or two...Dont know if you agree or not but I think there is no real place or decent books for absolute beginners to learn the code..plenty for form design but not for code, unless your at college I guess ya stuffed.
thanks for your help , Ill move on
Cheers
|
|
|
|
|
Dave Kreskowiak wrote: How you're doing this now isn't really the correct way of doing it in the first place. Normally, you'd have this data (and more) in a DataTable, or some other collection, and bind your controls to this data. Picking an item in the ComboBox would automatically select the rest of the records data.
I'm not really going to go into how this works because it's a more advanced technique. Something that will boggle your mind if you don't understand how Select/Case works yet.
Yes I know its not the best, I am just trying to start! I was thinking of using the case satement so later on I could work out how to include a form so that aircraft and rates could be added at will.
I have the labels etc working using if statements but was trying to look ahead. Perhaps too far
Your right its 101 but the only advice I can get re learning to code is to find a patient and experienced friend to assist or to just ask questions here. As you may be able to tell from my manner..I have no friends ..so it leaves me one option!
|
|
|
|
|
I taught myself out of the reference manuals for various languages. I used the books off the shelf for a basis to apply what I saw in the references. So how did I learn the language? Hit F1...
|
|
|
|
|
|
idyot wrote: So are u saying that I dont need to declare this as a variable and instead just use cmbPlanes.Text?
Yeah, I think Dave has this all covered, but...
The combo box contains the selected text. If all you want to do is know what the selected text is, there's no point moving it to another variable, but if yuo have a need to do that, you need to set the value of that variable, it won't set itself.
idyot wrote: second....setting a breakpoint is beyond me at this stage..I have no idea how to do that.
OK, this is a major thing to know, this will help you a lot. If you put your cursor on a line of code and hit F9, a little dot will appear in the code. Assuming you're running in debug mode ( which is the default ), when you press F5 and the program runs, it will stop at this line of code. You will be able to see the watch window in the bottom area, in this you can type things like cmbPlanes, and you'll see the value of the variable, and if it has properties, you can browse them. You can even call methods in this box, and they will execute immediately, or type things like Airplanes = "Messerschmidt" and the value will change. This is an invaluable tool for working out what's going on inside your code, especially when you don't know why it's not working. You can just hover the mouse over a variable while the code is at a breakpoint and see it's value, so this would have told you, in this case, that Airplane was not being set to the selected text. You can also use the function keys or menu items in the debug menu to step through code, or set which code runs next, so you can really trace exactly what your code is doing, and how this affects the state of your application.
Hope that helps.
If you're remotely willing to consider C#, I can recommend some good books. Actually, even if you bought a book like 'Inside C#' and used it to learn some overall concepts, C# and VB.NET are basically the same, just different formatting.
Christian Graus - Microsoft MVP - C++
Metal Musings - Rex and my new metal blog
"I am working on a project that will convert a FORTRAN code to corresponding C++ code.I am not aware of FORTRAN syntax" ( spotted in the C++/CLI forum )
|
|
|
|
|
Gday again.
Yeah Ive been working through it all using F1.....niot easy when you dont really know what ya searching for but here is where Im at!
I got it working using the case select after what you said earlier. It made sense after I thought about it for a while, so Im pretty happy with that now.
Where Im stuck now (hesitating to ask cos its 101 stuff again) is converting a string to a value so it can be used for calculations. Looked in books , looked in F1 and have this working but I doubt its the right way
lblRate.Text = Format(lblRate.Text, "currency") and
lblTotalAircraftCost.Text = AircraftRate * (Val(txtAircraftHours.Text))
Now Im sure your all wetting ya'selves laughing right now, but Im 100 miles ahead of where I was 8 hours ago so Im happy...and happy to give ya'all a laugh at my expense!
Cheers
Mate Id be happy to consider anything if u know of any decent books, I dont wanna clog the forum up with uneducated stupid questions...you know I reckon this is like golf...frustrating as hell but when ya get that one thing that goes right it keeps ya coming back for more!
|
|
|
|
|
idyot wrote: Now Im sure your all wetting ya'selves laughing right now
Not at all - I remember being new to all this stuff, I'm not THAT old or cynical :P
There are many ways to turn a string into a number. By far the best is to do this:
Dim hours as int
if (int.TryParse(txtAircraftHours.Text, hours)) then
lblTotalAircraftCost.Text = AircraftRate * hours
end if
Now, here's a funny thing. I don't use VB.NET. I help here because most questions I can answer as they relate to the framwork. So, I *think* this works because VB will turn a number into a string by magic ( I think your code was doing this also ). int.TryParse *definately* takes a string and an int, and if it can convert the string to an int, it sets the int value and returns true. This means it checks for you and won't blow up ( as other methods will ), if the string is not convertible.
idyot wrote: frustrating as hell but when ya get that one thing that goes right it keeps ya coming back for more!
Yeah, I can still remember how excited I was when I got my first little c++ projects to do something.
The book Inside C# by Tom Archer is a pretty decent overview of the C# language. If you get it, be sure to get the second edition, even that is out of date. But, it's a good, language focused book.
Christian Graus - Microsoft MVP - C++
Metal Musings - Rex and my new metal blog
"I am working on a project that will convert a FORTRAN code to corresponding C++ code.I am not aware of FORTRAN syntax" ( spotted in the C++/CLI forum )
|
|
|
|
|
Hey I got that working ok...thanks heaps!
Last thing for now ..if you could at least point me in the right direction and Ill try to work the rest out
The combo box holds a collection of items, right now they are checked directly in Select Case, what I would like to do now, is , as suggested (I think) before by Dave is to set it up so that the using the dropdown menu to select the aircraft, automatically populates the labels etc with data from a table somewhere.
The idea being the a new aircraft can be added, prices change, aircraft removed etc..all from another form, without having to go into the code to change aircraft names/rates etc. And I am aware that its prolly way above my current skill level but I wouldnt mind having a crack
Now I dont expect you to tell exactly how to do it but I would appreciate someone telling me what it is Im searching for in the MSDN or other. Often Im finding the problem is not knowing the right stuff to search for..
|
|
|
|
|
The core question is, how will you store the information ? I'd lean towards an XML file, which means you need to go to the w3c site to read their tutorials on XPath, so you know how to search your XML to get the values out. A database is probably easier to search, but more work to set up. SQL Server Express is free, if you wanted to try that instead.
If you set up XML like
<airplanes>
<plane>
<name>Messerschmidt
<year>1942
<origin>German
<passengers>2
( or whatever data you want, obviously )
then you can load it into an XmlDocument with the Load method, and do a foreach on document.SelectNodes("/airplanes/plane") which will give you a node for each group, then you can do node.SelectSingleNode("name") for the node with the name, etc.
Christian Graus - Microsoft MVP - C++
Metal Musings - Rex and my new metal blog
"I am working on a project that will convert a FORTRAN code to corresponding C++ code.I am not aware of FORTRAN syntax" ( spotted in the C++/CLI forum )
|
|
|
|
|
I have finally found a good VB.NET book, purchased it today and am already through the first 4 chapters....Deitels How to program in Visual Basic.NET. Its the first one Ive found that actually DOES talk about HOW to program in VB.NET and doesnt spend 75% of the book on form design!
Ordered the Inside C# book you mentioned, by the time it arrives I should have more of an idea of whats going on!
Cheers
|
|
|
|
|