
NekoManu
Avatar/Signature-
Posts
75 -
Joined
-
Last visited
Content Type
Profiles
Forums
Blogs
Events
Articles
Resources
Downloads
Gallery
Everything posted by NekoManu
-
I'm filling a Combox with values from a database. After that I get the last value from another table and want to position the combobox to the correct value. The questions is how? For Each BadgeItem In frmMainForm.cboBadge.Items If BadgeItem.Badge = myDataRow.Item("Data") Then 'Set correct index, but how? End If Next
-
I have never tried this before, so I have been looking for a workng example. So far no luck. I want to open an Excel 2007 file in VB.Net. When I try I get an error: Old format or invalid type library. (Exception from HRESULT: 0x80028018 (TYPE_E_INVDATAREAD)) I have no idea what is going on. This is the code I'm using: Private Sub btnExcel_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnExcel.Click Dim xlApp As Excel.Application Dim xlWorkBook As Excel.Workbook Dim xlWorkSheet As Excel.Worksheet xlApp = New Excel.ApplicationClass xlWorkBook = xlApp.Workbooks.Open("C:\Test.xlsx") xlWorkSheet = xlWorkBook.Worksheets("sheet1") 'display the cells value B2 MsgBox(xlWorkSheet.Cells(2, 2).value) 'edit the cell with new value xlWorkSheet.Cells(2, 2) = "http://vb.net-informations.com" xlWorkBook.Close() xlApp.Quit() releaseObject(xlApp) releaseObject(xlWorkBook) releaseObject(xlWorkSheet) End Sub Private Sub releaseObject(ByVal obj As Object) Try System.Runtime.InteropServices.Marshal.ReleaseComObject(obj) obj = Nothing Catch ex As Exception obj = Nothing Finally GC.Collect() End Try End Sub
-
I want to insert names into a database. Everything works fine until I want to insert a name with a quote. My insert command is: strSql = "Insert Into Individual (Name, FirstName) Values ('" & strINDIName & "', '" & strINDIFirstName & "')" This works fine when I want to insert a name like: Cain But it does NOT work with: O'Cain
-
Thanks I seems to work. Here is how to get rid of anything that is not a letter: Regex.Replace(InString, @"[^a-zA-Z]", "")
-
I have a string and I want to remove anything that is not a letter. I know I can use the replace method, but then I have to check for everything. I hope there is a better way of doing this.
-
I have a Usercontrol with a virtual method. When I use this control I want to override this method. I don't know how to do this. Can anybody help Please? This is the Control: namespace soReport { public partial class ReportContainer : UserControl { private string _ProfileName = ""; private string _ReportName = ""; public ReportContainer(string ReportName) { InitializeComponent(); _ReportName = ReportName; } private void ReportContainer_Load(object sender, EventArgs e) { RegistryKey ReportKey = Registry.CurrentUser.OpenSubKey(soSystem.RegistryEntry + soSystem.ApplicationTitle + "\\Reports\\" + _ReportName + "\\" + _ProfileName, true); if (ReportKey == null) ReportKey = Registry.CurrentUser.CreateSubKey(soSystem.RegistryEntry + soSystem.ApplicationTitle + "\\Reports\\" + _ReportName + "\\" + _ProfileName); GetContainerOptions(ReportKey); ReportKey.Close(); } public virtual void GetContainerOptions(RegistryKey ReportKey) { } public string ProfileName { get { return _ProfileName; } set { _ProfileName = value; } } } } In the form where I use this control I want to override GetContainerOptions.
-
I know BUT I want to write those settings to the registry automatically. If I use the closing event of the form, I need to call the method for writing the settings each time I use my control. Like in the Load of the control, I will have the settings each time I use the control. The same way I want to write the settings each time I use the control.
-
I have a UserControl where in the Load Event I Read the settings from the registry. I also want to write those settings back to the registry. My question is which event do I use? What is the opposite of Load? Is there something like Unload?
-
The thing is that it works when I open it (the project) in the solution in which the baser form is. If I open the project in a different solution it does not work. Very strange, but then again it is Microsoft
-
I think it is working now. There must have been something wrong with the references. Thank you.
-
I did add the project to the references and added the project to my solution, but when I call the form, the code is not executed.
-
That works if my form is in the same project as the rest. What I want to do is create a form in a separate project and then call it from another project.
-
I have a project with myForm. This form is based on a form and uses the icon of the parent form. I also have a project soReport. In this Project I want to create a form based om myForm. In my application I do the following: myForm dlgMyForm = new myForm(); dlgMyForm.showDialog(); When I run the application I get a warning that there is no user code and such, and the code in myForm does NOT work. Can anyone explain to me what I'm doing wrong and how it should be done?
-
I could do that, but than I have to write the same code in each textbox. Or am I wrong with that?
-
I not sure I understand the question, but I'll try to explain what I want to do. I want to write the test in the form, because they are different for each time you use the control. Like testing if a textbox is empty or testing if it is a valid e-mail address, that sort of stuff. I need the ValidTextBox() method in the control, because otherwise I can't do the test there. Like I said before, if there is a better way to do this, please let me know.
-
I want to create a user control, based on a textbox, that validates the input. I have tried it again and again but I don't know how to do this. This is what I have come up with, but if there are other and better ways to do this, please let me know. namespace soControls { public partial class MNLTextBox : TextBox { private string _OldValue; private string _ErrorMessage1 = ""; private string _ErrorMessage2 = ""; private ErrorProvider TextBoxErrorProvider; public MNLTextBox() { InitializeComponent(); this.Validating += new CancelEventHandler(MNLTextBox_Validating); this.Validated += new EventHandler(MNLTextBox_Validated); TextBoxErrorProvider = new ErrorProvider(); } private void MNLTextBox_Validating(object sender, CancelEventArgs e) { if (this.Text != _OldValue) { if (ValidTextBox()) { _OldValue = this.Text; if (((MNLForm)MNLForm.ActiveForm).DBStatus == soSystem.cUnChanged) ((MNLForm)MNLForm.ActiveForm).DBStatus = soSystem.cEdit; } else { e.Cancel = true; this.Select(0, this.Text.Length); this.TextBoxErrorProvider.SetIconAlignment(this, ErrorIconAlignment.MiddleLeft); this.TextBoxErrorProvider.SetError(this, (_ErrorMessage1.Length > 0 ? _ErrorMessage1 : "Unidentified Error") + (_ErrorMessage2.Length > 0 ? "\n" + _ErrorMessage2 : "")); } } } private void MNLTextBox_Validated(object sender, EventArgs e) { this.TextBoxErrorProvider.SetError(this, ""); } public virtual Boolean ValidTextBox() { return true; } public string OldValue { get { return _OldValue; } set { _OldValue = value; } } public string ErrorMessage1 { get { return _ErrorMessage1; } set { _ErrorMessage1 = value; } } public string ErrorMessage2 { get { return _ErrorMessage2; } set { _ErrorMessage2 = value; } } } } My big problem is the ValidTextBox() method. When I use this control on a form, I want to write a new method that does the actual validation for that specific control (e.g. checking if a field is empty). I tried with override, but that does NOT seem to work, because I get the error that there is no such function to override.
-
I have a dataset with records from my database (MS Access) I now want to get that information to my form. I know how to get strings out of the dataset, but I can't get the integers and booleans. I tried using a cast, but that doesn't seem to work. This is what I want to do: cboNumber.SelectedIndex = DS.Tables[0].Rows[0].ItemArray[4]; where ItemArray[4] is an integer. And the same for booleans Can anyone tell me how to do this?
-
I tried your example and it does work. But I'm using a datagridview.
-
I can not build when using that code. I tried with: grdWord.CurrentCell = new DataGridViewCell(0, 0); which gives the error: Cannot create an instance of the abstract class or interface 'System.Windows.Forms.DataGridViewCell' I tried with: grdWord.CurrentCell = new DataGridViewCell[0, 0]; which gives the error: Cannot implicitly convert type 'System.Windows.Forms.DataGridViewCell[*,*]' to 'System.Windows.Forms.DataGridViewCell'
-
I have an empty datagridview. I set the Rowtemplate.Height = 28 The height of the first row of the datagridview stays 22, but all the following rows are 28. How can I make the first row the same as the rest? Or am I doing it wrong?
-
How do I set the current cell programatically? I tried the following code, but I still need to click on the cell before it is selected. Is there a way to make the a cell the selected cell? this.Datagridview.CurrentCell = this.Datagridview.Rows[6].Cells[1];
-
This is some code I found somewhere, but I still can't get the bloody thing to do any updates, inserts. #region Using directives using System; using System.Collections.Generic; using System.ComponentModel; using System.Data; using System.Data.OleDb; using System.Drawing; using System.Text; using System.Windows.Forms; using soForms; #endregion namespace Thai_Dictionary { partial class frmWords : MNLForm { OleDbConnection myConn; OleDbDataAdapter myAdapter; DataSet ds; OleDbParameter workParam = null; string myQuery = "select ID, Word from Thai"; public frmWords() { InitializeComponent(); ConnectToData(); // establish database connection and create DataSet grdThaiWords.DataSource = ds.Tables[0].DefaultView; DataTable t = ds.Tables[0]; t.RowChanged += new DataRowChangeEventHandler(Row_Changed); } private void Words_Load(object sender, EventArgs e) { } public void ConnectToData() { ds = new DataSet(); myConn = new OleDbConnection(System.Configuration.ConfigurationSettings.ConnectionStrings["Dictionary"].ConnectionString); myAdapter = new OleDbDataAdapter(); myAdapter.SelectCommand = new OleDbCommand(myQuery, myConn); myAdapter.Fill(ds, "Thai"); insertCommand(); updateCommand(); } public void updateCommand() { string updateQuery = "Update Thai Set Word = @Word WHERE ID = @ID"; myAdapter.UpdateCommand = new OleDbCommand(updateQuery, myConn); workParam = myAdapter.UpdateCommand.Parameters.Add("@Word", OleDbType.Char); workParam.SourceColumn = "Word"; workParam.SourceVersion = DataRowVersion.Current; } private void Row_Changed(object ob, DataRowChangeEventArgs e) { DataTable t = (DataTable)ob; Console.WriteLine("RowChanged " + e.Action.ToString() + "\t" + e.Row.ItemArray[0]); } public void insertCommand() { string insertQuery = "Insert into Thai VALUES (@Word)"; myAdapter.InsertCommand = new OleDbCommand(insertQuery, myConn); workParam = myAdapter.InsertCommand.Parameters.Add("@Word", OleDbType.Char); workParam.SourceColumn = "Word"; workParam.SourceVersion = DataRowVersion.Current; } public void UpdateValue() { try { myAdapter.Update(ds, "CardTest"); Console.Write("Updating DataSet succeeded!"); } catch (Exception e) { Console.Write(e.ToString()); } } } }
-
I tried it in a test program and it worked. Today I put it in my library. This is a different namespace and a different solution. As you can guess this does not work anymore. Any idea's on how to solve this? The thing is that I have a property on soSytem with the name of the image. When I create the StartUp form, I want to load the image and then display it.