|
I have a dataGrid that is populated by SQL table. The Datagrid has two dynamic columns - that I created to for calculations. I want to sort the grid on frmload by one of the dynamic columns is that possible - if so; what will be the best way to do this?
Thank You
|
|
|
|
|
hi
Use Orderby in your SQl statement.
Vuyiswa Maseko,
Sorrow is Better than Laughter, it may Sudden your Face, but It sharpens your Understanding
VB.NET/SQL7/2000/2005
http://vuyiswamb.007ihost.com
http://Ecadre.007ihost.com
|
|
|
|
|
How will I do that? - this is my code below - the Sql statement will order by a column in the table - in my situation I have a column that is not part of the table it was created dynamically - below is my code
Dim command1 As New SqlCommand("Select * FROM LateOrders_query_view order by requested_date desc", cnn1)
Dim SqlReader As SqlDataReader
cnn1.Open()<br />
<br />
Dim dt As New DataTable("LateOrders_query_view")<br />
Dim DirAdapter As New SqlDataAdapter(command1)<br />
DirAdapter.Fill(MyDataSet, "LateOrders_query_view")<br />
<br />
dgOrderReport.DataSource = MyDataSet.Tables("LateOrders_query_view").DefaultView<br />
<br />
'Create Dynamic Columns call related function<br />
Dim dc As DataColumn<br />
dc = New DataColumn("Days Open") ', Type.GetType("System.double"))<br />
MyDataSet.Tables(0).Columns.Add(dc)<br />
fncGetOpenDays()<br />
<br />
Dim dc2 As DataColumn<br />
dc2 = New DataColumn("Days Late")<br />
MyDataSet.Tables(0).Columns.Add(dc2)<br />
fncGetDays()
Is there away for me to sort by a dynamic column (the dynamic column is not part of my table in the database)
Thank You
|
|
|
|
|
I figured how to make it sort - its pretty simple here is the code
Dim dc2 As DataColumn<br />
dc2 = New DataColumn("Days Late")<br />
With dc2<br />
.AutoIncrement = True<br />
.AutoIncrementSeed = 1<br />
.AutoIncrementStep = 1<br />
End With
Now I just need to get it to do this on load not when I click on that column...
Help will be appreciated. Thanks
Thank You
|
|
|
|
|
hi KA National Marker
am sorry i could not reply, it was friday, i dont access the net on weekends. i do that when am at my workplace. am glad you find your answer.
i know you are smart after all
Vuyiswa Maseko,
Sorrow is Better than Laughter, it may Sudden your Face, but It sharpens your Understanding
VB.NET/SQL7/2000/2005
http://vuyiswamb.007ihost.com
http://Ecadre.007ihost.com
|
|
|
|
|
Hello!
I have two rich text boxes RTB1 and RTB2.
I have text with different fonts,colors and styles in RTB1 and RTB2 is empty.
when i use this code:
RTB2.text = RTB1.text
RTB2 displays the text but with its default font and color.
How can i keep the fonts and styles used in source text box to the destination textbox.
Thanks for Any help!
colgateas900197
|
|
|
|
|
use the copy and paste methodes:
RichTextBox1.SelectAll()
RichTextBox1.Copy()
RichTextBox1.DeselectAll()
RichTextBox2.Paste()
tested it with bold text and works
hope this helps
If my help was helpfull let me know, if not let me know why.
The only way we learn is by making mistaks.
|
|
|
|
|
Thanks! It works....
It work for different colors and fonts as well.
Thanks again!
colgateas900197
|
|
|
|
|
hi,
use following code
rtb2.rtf = rtb1.rtf
hope this helps
Rupesh Kumar Swami
Software Engineer,
Integrated Solution,
Bikaner (India)
My Company
|
|
|
|
|
thank you Rupesh!
it works...
i have used (as suggested by TDDragon)
RTB1.SellectAll()
RTB1.copy()
RTB1.deselectAll()
RTB2.Paste()
It also works!
Could you please tell me what is the difference? What are limitations? These are same or one has advantage over other?
colgateas900197
|
|
|
|
|
Rupesh Kumar Swami... wrote: rtb2.rtf = rtb1.rtf
is a single line of code.
SoInnocentIAm... wrote:
RTB1.SellectAll()<br />
RTB1.copy()<br />
RTB1.deselectAll()<br />
RTB2.Paste()
is four lines of code.
Although for all intents and purposes there is no difference, RPS's solution is meant to do do what you wanted, while TDDragon's suggestion does what you wanted as a side effect.
I would recommend using RPS's code, simply because keeping your code as small as possible is always preferable.
My advice is free, and you may get what you paid for.
|
|
|
|
|
Hi, Am new to Dot net. I would like to print the data in the data grid in a VB.NET application.
Anyway to go round this?
All effort put is highly appreciated.
|
|
|
|
|
|
Thanks you for the reply
Am using print document class and datagridView. Using vs 2005.
|
|
|
|
|
I don't know how important it is for you to print from your created app. But you can try exporting the grid to an excel spreadsheet which is very easy - and you will be able to print from excel.
Thank You
|
|
|
|
|
|
Is there any benefit to doing this:
If obj isnot Nothing Then
obj.Dispose
obj = Nothing
End If
I'm not sure there is. Your views are appreciated!
Tim
|
|
|
|
|
intonet wrote: Is there any benefit to doing this
Yes, it prevents an exception being thrown when you attempt to call a method on Nothing.
|
|
|
|
|
intonet wrote: I'm not sure there is.
You save yourself from being entrapped with the dreaded exception like this:
System.NullReferenceException Object Reference Not Set To An Instance Of An Object
|
|
|
|
|
How to Set CustomPaperSize For Crystal Report From Coding in Vb.net?
prabumj@gmail.com
|
|
|
|
|
do you want to design crystal report on a custom page size or just want to set the size of paper at printing time
Salman Sheikh
|
|
|
|
|
hi All
i have two vb.net Projects,and i have added them together in one Solution and its fine. i want to calla form of the second Project in the first project, when Project one is finished executing it task. how do i achieve that
Thanks
Vuyiswa Maseko,
Sorrow is Better than Laughter, it may Sudden your Face, but It sharpens your Understanding
VB.NET/SQL7/2000/2005
http://vuyiswamb.007ihost.com
http://Ecadre.007ihost.com
|
|
|
|
|
add a reference from the project that does the calling to the other project (right mouse click on project select add reference tab projects)
then add an imports statement to the form (or class) that does the calling
imports project2
after that you can use everything from project2 as if it was in project1
Remarks:
-you can do it without the imports too
just add project2.Form1 when calling the form1 in project2 instead of form1
-when you have a reference from project1 to project2 you cannot add a reference from project2 to project1 this would couse a circular dependency (straight from the error from vs.net )
hope this helps
|
|
|
|
|
Hi thanks for the Reply
i have done as you said, and i click on the Project Tab and select the available Project in this case ProjectB and select it in the selected components and when i click ok, it gives me the following Error.
a Reference to 'ProjectB' could not be added. An assembly must have a dll extension in order to be referenced.
Help
Vuyiswa Maseko,
Sorrow is Better than Laughter, it may Sudden your Face, but It sharpens your Understanding
VB.NET/SQL7/2000/2005
http://vuyiswamb.007ihost.com
http://Ecadre.007ihost.com
|
|
|
|
|
ah yes forgot about that
in properties of projectB put application type (on application tab) to 'class library'
this does mean you cannot start you application from a form on projectB after that it should work fine
If my help was helpfull let me know, if not let me know why.
The only way we learn is by making mistaks.
|
|
|
|