|
Ya u can change the row color by using
For all rows:
DataGrid1.DefaultCellStyle.BackColor = Color.DarkGray
For alternating row style:
DataGrid1.AlternatingRowsDefaultCellStyle.BackColor = Color.Beige
Janani
|
|
|
|
|
thakn you but i want to change only one row.
for example
DataGrid1.CurrentRowIndex = 3
i want to change this row.
and there not AlternatingRowsDefaultCellStyle ana DefaultCellStyle in datagrid of peculiarity
or there?
if there, how can i use?
|
|
|
|
|
This is for changing the particular row color.
Try it:
DataGrid1.Rows(3).DefaultCellStyle.BackColor = Color.Azure
For which row, u want, change the row value only.
|
|
|
|
|
excuse me..i didnt write this.i use vb.net.
i cant this in vb.net
DataGrid1.Rows(3).DefaultCellStyle.BackColor = Color.Azure
|
|
|
|
|
This is in VB.net only.
I worked out.
It was changing the particular row.
Janani
|
|
|
|
|
Hi
I want coding for a text box in which if i press a '.' Dot from keyboard then
a message should be displayed and that '.' Dot must not be seen in that TextBox. How can i do that.
Please help me.
I have coding for text box in which if i press more then 1 '.' dot then message will be seen But how can i do for first '.'dot?
If KeyAscii >= 48 And KeyAscii <= 57 Or KeyAscii = 46 Then
If KeyAscii = 46 Then
If InStr(TxtMRP.Text, ".") Then
KeyAscii = 0
MsgBox "You can enter One Decimal at a Time", vbInformation
Exit Sub
End If
End If
End If
Withe Regards
Alok Singh
|
|
|
|
|
Ya u can do this by using regular expression regex.
Janani
|
|
|
|
|
regex
What is that?
Kindly tell me
i will be very thankful to you.
with regards
Withe Regards
Alok Singh
|
|
|
|
|
Dim Id As Boolean = ValidateSearch(TextBox1.Text)
If Id = True Then
--------> U do ur functionality.
else
MsgBox("Don't Enter Dots", MsgBoxStyle.OkOnly)
end if
This is the regular expression. U include it in ur code behind.
Public Function ValidateSearch(ByVal texttype As String) As Boolean
Dim RoomType As System.Text.RegularExpressions.Regex _
= New System.Text.RegularExpressions.Regex("[0-9]+$")
Dim M As System.Text.RegularExpressions.Match = RoomType.Match(texttype)
Return M.Success
End Function
This regular expression will accept only numbers.
Like this there are several expressions, like characters etc.
-- modified at 2:05 Monday 30th October, 2006
With regards Janani
|
|
|
|
|
Thank you very much
Janani Divya
Withe Regards
Alok Singh
|
|
|
|
|
Is there a way to expose classes belonging to a web-service without referencing the dll?
Every time I add the web-service as regular web reference then I lose the ability to access all the classes belonging to the web-service. Currently the only Web Methods I have access to are located in the service.asmx file. If I could access the classes belonging to the web service then I could use it to pass strongly typed collections and keep my functions grouped accordingly. Thanks so much!
- Paul
|
|
|
|
|
Hi members, I've written a prog that enables the user to move controls around on the form using the mouse at runtime. I would like to know how to save the position of these controls so that their positions are the same as they left them, when they're loaded up again.
|
|
|
|
|
You will have to save the position information in an external location (config file, registry, database, etc.). Generally you would load the settings when the form loads and save the settings upon closing of the form.
Mike Lasseter
|
|
|
|
|
Cheers Mike, but any idea how I would go about doing this? Any help at all is helpful.
EvSott
|
|
|
|
|
Ev,
Here is some code that might work for you.
This is about the simplest way I know to do this, and I do mean simple.
It uses a local xml file.
I threw this together and tested it and it works, but that's about it.
I wouldn't call it production grade, but...
Create a new Windows project and put two buttons on it named btnSave and btnLoad.
Put a textbox, combobox, picturebox and a listbox on it.
Set their Tag properties to "SETTABLE".
Set the backcolor of the picturebox to red or something you can see.
You can play with adding 50 or 100 or so to the positional propertyValues in the Load section, so you can easily tell what it's doing.
Give it a shot.
If you don't have multiple users, and won't need to use the operator key, you can just set it to 0.
Also, you will likely want to change it to use your available RDBMS (SQL Server(/Express), Access, mySQL) as the storage medium. Then you can just store the xml in a text field.
(Also, you really should change the bang notation ("!") to something more substantial, preferably a strongly-typed dataset table. I just used it for speed and don't recommend using it in production.)
There are many other ways to do this, (key/value pair strings, dictionaries, serialization and such), but this oughta give you some ideas and get you going. Good luck.
Public Class Form1
Private ds As DataSet
Private m_dt As DataTable
Private dr As DataRow
Private OperatorKey As String
Private Sub Form1_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
'Code to retrieve operator key
OperatorKey = "42"
End Sub
Private Sub btnSave_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnSave.Click
SaveSettings(Me, m_dt, OperatorKey)
End Sub
Private Sub btnLoad_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnLoad.Click
LoadSettings(OperatorKey)
End Sub
Private Sub SaveSettings(ByVal pControl As Control, ByVal pDataTable As DataTable, ByVal operKey As Object)
Dim dt As DataTable
Dim dr As DataRow
If pDataTable Is Nothing Then
dt = New DataTable("ControlSettings")
dt.Columns.Add("formName", GetType(String))
dt.Columns.Add("operatorKey", GetType(String))
dt.Columns.Add("controlName", GetType(String))
dt.Columns.Add("propertyName", GetType(String))
dt.Columns.Add("propertyValue", GetType(String))
Else
dt = pDataTable
End If
For Each ctl As Control In pControl.Controls
'SaveSettings(ctl, dt, oprkey)... you could call this procedure recursively if you want to do so ... have fun
If ctl.Tag IsNot Nothing Then
If CStr(ctl.Tag) = "SETTABLE" Then 'you set this
'Store the control's location properties - Top, Left, Height, and Width
dr = dt.NewRow
dr!formName = Me.Name
dr!operatorKey = operKey.ToString
dr!controlName = ctl.Name
dr!propertyName = "Top"
dr!propertyValue = ctl.Top.ToString
dt.Rows.Add(dr)
dr = dt.NewRow
dr!formName = Me.Name
dr!operatorKey = operKey.ToString
dr!controlName = ctl.Name
dr!propertyName = "Left"
dr!propertyValue = ctl.Left.ToString
dt.Rows.Add(dr)
dr = dt.NewRow
dr!formName = Me.Name
dr!operatorKey = operKey.ToString
dr!controlName = ctl.Name
dr!propertyName = "Width"
dr!propertyValue = ctl.Width.ToString
dt.Rows.Add(dr)
dr = dt.NewRow
dr!formName = Me.Name
dr!operatorKey = operKey.ToString
dr!controlName = ctl.Name
dr!propertyName = "Height"
dr!propertyValue = ctl.Height.ToString
dt.Rows.Add(dr)
dt.AcceptChanges()
End If
End If
Next
dt.WriteXml("TestControlSettings.xml", XmlWriteMode.WriteSchema)
End Sub
Private Sub LoadSettings(ByVal operKey As String)
Dim dt As New DataTable
Dim dv As DataView
Dim drv As DataRowView
Dim arrDR As DataRow()
Try
dt.ReadXml("TestControlSettings.xml")
Catch ex As Exception
'Not there yet.
Exit Sub
End Try
dv = dt.DefaultView
dv.RowFilter = ("operatorKey = '" & operKey.ToString & "' AND formName = '" & Me.Name & "'")
For Each drv In dv
If CStr(drv!formName) = Me.Name And CStr(drv!operatorKey) = operKey Then
Select Case CStr(drv!propertyName)
Case "Top"
CType(Me.Controls(CStr(drv!controlName)), Control).Top = CType(drv!propertyValue, Int32)
Case "Left"
CType(Me.Controls(CStr(drv!controlName)), Control).Left = CType(drv!propertyValue, Int32)
Case "Width"
CType(Me.Controls(CStr(drv!controlName)), Control).Width = CType(drv!propertyValue, Int32)
Case "Height"
CType(Me.Controls(CStr(drv!controlName)), Control).Height = CType(drv!propertyValue, Int32)
Case Else
'Big Problem - get bigger hammer
End Select
End If
Next
'Delete this operator's old rows
arrDR = dt.Select(dv.RowFilter)
For Each dr In arrDR
dr.Delete()
Next
dt.AcceptChanges()
'Save the table for later
m_dt = dt
End Sub
End Class
-- modified at 1:31 Saturday 28th October, 2006
|
|
|
|
|
Can't you just use the applicationsettings - propertybindings - location controls from the properties menu of the button?
|
|
|
|
|
I didn't even think about that...
Yup. Sure looks like ya could.
(We use the other approach at work, and store it all in Sql Server, cuz there's 300 forms and 50-500 operators per site, and some of em are terminal server... space and permissions issues and all that.)
Good catch.
Dave
|
|
|
|
|
I have a program that puts data into a DataGridView. When the user clicks a button the data is converted into a .csv file and saved. Then my program will open the .csv file in Excel. I've done this by adding a reference to the Microsoft Excel 8.0 Object Library and using the following code:
Dim xlTmp As Excel.Application<br />
xlTmp = New Excel.Application<br />
xlTmp.Visible = True<br />
xlTmp.Workbooks.Open(strCSVLocation)
This code works fine, unless the user does not have Excel installed on their machine. I know I could require that the user have Excel before installation, but my program must work for users without Excel too. Basically if a user HAS Excel it should open it for the user. If the user does NOT have Excel, it should just save the file. I thought I could accomplish this by putting the Excel.Application code into a try-catch block, but I'm still getting an unhandled exception as soon as I hit the button to save the csv and open Excel.
How can I check programmatically if a user has Excel or not?
|
|
|
|
|
check for the existance of the registry key for excel.applicaion:
HKEY_LOCAL_MACHINE\SOFTWARE\Classes\CLSID\{00024500-0000-0000-C000-000000000046}
before calling the code to create the Excel.Application object.
If the key is present, it should beok to open exel, if not just skip.
|
|
|
|
|
Need to write VB code to save application DataBases (Access) to another location of the users choice. Need help coding using SaveFileDialog control. Thanks.
Gib5531
|
|
|
|
|
|
Help, i face this error message
System.Data.OleDb.OelDbException:IErrorInfo.GetDescription failed with E_FAIL(0x80004005) at system.Data.OleDbCommand.ExecuteCommandTextErrorHandling(Int32hr)....
|
|
|
|
|
Means nothing to me. What were you doing at the time?
|
|
|
|
|
i have rename the tablename name and attribute name in the database.When the function call the database then it prompt out the error message.
i totaly no idea about it.
|
|
|
|
|
Without seeing the code that throws this error and knowing which line it fails on, it's pretty much impossible to tell you what happened.
Dave Kreskowiak
Microsoft MVP - Visual Basic
|
|
|
|