Many thanks for that. I shall proceed accordingly. :thumbsup:
kanchoette
Posts
-
Reference combobox used on another form? -
Reference combobox used on another form?I need to reference a combobox value (selectedvalue) on another form to the current form. How can I do this please? I tried setting the combobox modifier to 'Public' and while in NewForm using MainForm.myComboBox.selectedValue without success.
-
Regex questionI hace some code which starts:
if (textBox1.Text.Length > 0) { String pat = "*.csv"; Regex r = new Regex (pat, RegexOptions.IgnoreCase); Match m = r.Match(textBox1.Text); if (m.Success) { GetCSV(textBox1.Text); }
which is giving me the error: "parsing "*.csv" - Quantifier {x,y} following nothing." What am I doing wrong please? -
Setting DataGridView ColumnHeader textBeaucoup de mercis de votre aide. Beaucoup a apprécié.
-
Setting DataGridView ColumnHeader textI am using the following code to import a csv file into a datagridview:
using System; using System.Collections.Generic; using System.ComponentModel; using System.Data; using System.Drawing; using System.Linq; using System.Text; using System.Windows.Forms; using System.IO; namespace CSVImporter { public partial class Form1 : Form { public Form1() { InitializeComponent(); List<string[]> csv = parseCSV("C:\\text.csv"); DataTable newTable = new DataTable(); string[] headers = csv[0]; int counter = 0; foreach (string column in headers) { DataColumn colNewDGCol = new DataColumn(); colNewDGCol.ColumnName = "CSV" + headers[counter]; newTable.Columns.Add(colNewDGCol); newTable.Columns[counter].HeaderText = headers[counter]; counter++; } foreach (string[] row in csv) { newTable.Rows.Add(row); } dataGridView1.DataSource = newTable; } public List<string[]> parseCSV(string path) { List<string[]> parsedData = new List<string[]>(); using (StreamReader readFile = new StreamReader(path)) { string line; string[] row; while ((line = readFile.ReadLine()) != null) { row = line.Split(','); parsedData.Add(row); } } return parsedData; } } }
But the line: newTable.Columns[counter].HeaderText = headers[counter]; does not work. How can I create the appropriate column header text please? -
Casting error questionMany thanks for your reply. Sill me realised that I needed SelectedValue instead of selectedItem to do the job. The perils of late night coding .......
-
Casting error questionI am using:
foreach (DebtorDataSet.PaymentArrangementsRow row in debtorDataSet.PaymentArrangements.Rows) { if (row.PaymentArrangementID != -1 && row.PaymentTypeID == Convert.ToInt32(paymentCategoryComboBox.SelectedItem) && row.ArrangementComplete == false) { row.ArrangementComplete = true; row.ArrangementDate = DateTime.Today; } }
but this is giving me the error: 'Unable to cast object of type 'System.Data.DataRowView' to type 'System.IConvertible'' I am not sure how to correct this. Any help would be much appreciated please. -
Ascertain table bound to textBoxNo hacking. No excitement here :) My application contains several texboxes which are databound to table(s) containing date fields. The users have a habit of putting dates into the wrong textboxes (Grrrr!!) and then trying to correct the error(s) by attempting to have a blank (null) textbox via the backspace key. The system won't allow this. So, I am trying to create a function which a) understands which textbox it is checking b) locates the correct table databound to that textbox (my question) c) sets the associated table row field to System.DBNull.Value in order for my application to be satisfied with the user's correction. Hope that makes more sense. My apologies for the curt original question. I always assume that all coders are part of the Borg collective :) He he.
-
Ascertain table bound to textBoxHow can I find which table is bound to a textBox please?
-
Find MIN value in binding?If I want to locate the minimum value for a column in a datatable I would use something like:
int minArrangementID = (int) debtorDataSet.PaymentArrangements.Compute("MIN(PaymentArrangementID)", "PaymentArrangementID > 0");
How can I find the minimum value within a binding please?
-
Read row value from previous DataRowViewIf I want to grab a DataRowView I use: DataRowView arrangement = (DataRowView)BindingContext[debtorDataSet, "Debtor.FK_PaymentArrangements_Debtor"].Current; How can I get a DataRowView for the previous position without changing the position to do so please?
-
DBNull errorAlthough I have all datatable columns set to accept DBNull, my application throws this exception:
[global::System.Diagnostics.DebuggerNonUserCodeAttribute()]
public System.DateTime ArrangementDate {
get {
try {
return ((global::System.DateTime)(this[this.tablePaymentArrangements.ArrangementDateColumn]));
}
catch (global::System.InvalidCastException e) {
throw new global::System.Data.StrongTypingException("The value for column \'ArrangementDate\' in table \'PaymentArrangements\' is DBNull.", e);
}
}
set {
this[this.tablePaymentArrangements.ArrangementDateColumn] = value;
}
}I'm stumped (right now). Any pointers would be much appreciated please.
-
DataBinding removal errorThe project has changed and the data binding for the textbox is no longer required.
-
DataBinding removal errorI have a textBox databound to a datatable via the properties window. It works well. I now need to remove this databinding. When doing this, via the properties window, and setting the Text section of DataBindings back to 'None' I get this error when re-running the solution: 'object reference not set to an instance of an object' for line: firstPaymentDateTextBox.DataBindings["Text"].Format += new ConvertEventHandler(DebtConvert.DateToString); it seems that VS 2008 does not remove this line when resetting the databinding via the designer properties window. It there a way around this please? As I have a lot of databindings to remove it seems a little tedious for such a, otherwise, powerful IDE.
-
Form_Load event problemMany thanks for your reply. I had my load subscription within
private void InitializeComponent()
{}
-
Form_Load event problemWithin my Form I am using
this.Load += new System.EventHandler(this.ItemForm_Load);
private void ItemForm_Load(object sender, EventArgs e)
{
myDataSet.Merge(mainForm.newDataSet);
}However, the merge does not take place. Placing a breakpoint in the debugger shows that the ItemForm_Load never gets hit. Any pointers would be much appreciated.
-
ListView Context MenuMany thanks for the heads up. Much appreciated.
-
ListView Context MenuI am using MS VS 2008 and can find the ListView property ContextMenuStrip, but no property for ContextMenu. How can I activate (show) a ContextMenu when I right-click my ListView please?
-
How to open multiple pdf filesIs there a way to open multiple pdf files, via c# please?
-
ListView not populatngSorry, but I don't understand your reply. I'm using a) Create new listViewItem b) add subitems to listViewItem c) Add listViewItem to listview model. Which I use successfully elsewhere in my project. I am not sure what your 'item.Text = "MyTitle";' pertains to.