|
listViewNV_KeyPress function it does not run ? I am using C # 2005, I checked the KeyPress event that it does not run listViewNV_KeyPress function, the function is similar: KeyDown and KeyUp run normally
private void listViewNV_KeyPress (object sender, KeyPressEventArgs e)
{
...
}
|
|
|
|
|
|
Hi friends :
I want to know that how can I access to a column contents?
because "Gridcol" just returns columns header and in "Finaldgv" just columns header will be added. Actually I need each columns header text with its contents. here ,I indicated the main line which copy "Gridcol" into "Finaldgv" by "****"
this is my code :
private static DataGridView Firstdgv;
private static DataGridView Finaldgv = new DataGridView();
private static List<string> SelectedColumns = new List<string>();
private static List<string> AvailableColumns = new List<string>();
public void Print_DataGridView(DataGridView dgv1)
{
PrintPreviewDialog ppvw;
try
{
Firstdgv = dgv1;
AvailableColumns.Clear();
foreach (DataGridViewColumn c in Firstdgv.Columns)
{
if (!c.Visible) continue;
AvailableColumns.Add(c.HeaderText);
}
FrmPrintOptions dlg = new FrmPrintOptions(AvailableColumns);
if (dlg.ShowDialog() != DialogResult.OK) return;
PrintTitle = dlg.PrintTitle;
PrintAllRows = dlg.PrintAllRows;
FitToPageWidth = dlg.FitToPageWidth;
SelectedColumns = dlg.GetSelectedColumns();
ppvw = new PrintPreviewDialog();
Finaldgv.AutoGenerateColumns = false;
foreach (DataGridViewColumn GridCol in Firstdgv.Columns)
{
if (!GridCol.Visible) continue;
if (!SelectedColumns.Contains(GridCol.HeaderText)) continue;
Finaldgv.Columns.Add((DataGridViewColumn)GridCol.Clone()); ****
}
DGVPrinter obj = new DGVPrinter();
obj.PrintPreviewDataGridView(Finaldgv);
}
catch (Exception ex)
{
MessageBox.Show(ex.Message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
}
}
|
|
|
|
|
If you are looking for the values within the DataGridView fro a particular column, you don't access them via the Column directly: they are all organised by Row, then by column within the row.
So if you want the column header and all the values it contains, you can pick up the header from the Column as you are doing, but you then need to loop through the Rows property to collect the values from the DataGridViewRow.Cells collection - each entry in which contains the appropriate Column value.
This message is manufactured from fully recyclable noughts and ones. To recycle this message, please separate into two tidy piles, and take them to your nearest local recycling centre.
Please note that in some areas noughts are always replaced with zeros by law, and many facilities cannot recycle zeroes - in this case, please bury them in your back garden and water frequently.
|
|
|
|
|
can you explain more in details? because I am beginner how can I apply your solution in my code? can you write it for me?
thank you so much.
|
|
|
|
|
You really shouldn't need more details, but...
Lets just look at your questions in reverse order:
babak14 wrote: can you write it for me?
Yes, I could. But then I'd have to send you a pro-forma invoice first, and I don't think you want to pay my rates...
babak14 wrote: how can I apply your solution in my code?
That's really down to you: I don't have an exact idea what you are trying to do, so I can't be very specific.
babak14 wrote: can you explain more in details? because I am beginner
This is the main reason I'm not giving you code: we don't don't do homework, and it isn't good for you to just be given a solution. You learn more by doing it yourself!
But... this might help:
Data organisation in a DataGridView (DGV for short)
Property: DataGridView.Columns
Contains a collection of DataGridViewColumn objects, each of which describes the column - the header, the column data source and so on. This does not contain any actual values displayed in the DGV.
Property: DataGridView.Rows
Contains a collection of DataGridViewRow objects, each of which holds a collection of cells, each of which corresponds to the value for that row within a column.
Property: DataGridViewRow.Cells
Contains a collection of DataGridViewCell objects, each of which holds a value for the column.
So to get all the values you loop through each row, then access the cells for that row:
(this code won't help you much in practice - it's not something we would actually do in the real world but it should demo what I mean:
foreach (DataGridViewRow row in myDataGridView.Rows)
{
foreach (DataGridViewCell cell in row.Cells)
{
Console.Write("{0} ", cell.Value);
}
Console.WriteLine();
}
Run the code, and you should get the idea.
This message is manufactured from fully recyclable noughts and ones. To recycle this message, please separate into two tidy piles, and take them to your nearest local recycling centre.
Please note that in some areas noughts are always replaced with zeros by law, and many facilities cannot recycle zeroes - in this case, please bury them in your back garden and water frequently.
|
|
|
|
|
thank you.
you helped me a lot
|
|
|
|
|
You're welcome!
This message is manufactured from fully recyclable noughts and ones. To recycle this message, please separate into two tidy piles, and take them to your nearest local recycling centre.
Please note that in some areas noughts are always replaced with zeros by law, and many facilities cannot recycle zeroes - in this case, please bury them in your back garden and water frequently.
|
|
|
|
|
Hi,
I would like to know how can I speed up the load of the SplashScreen and then display the loading processes on it or at least display a percentage which shows the status of loading until the application is loaded.
Technology News @ www.JassimRahma.com
|
|
|
|
|
A better solution that your users would appreciate more is to actually speed up the loading of your application rather then pointing out how slow it is to start up . This is typically accomplished by:
1) lazy load / load on demand
2) background loading
3) determine what is causing the long delays and fixing it
Typically one major issue is trying to load an entire datebase into memory. Yeah, easier to code, but you don't really need an entire database at start up. Switch to stored procs and retrieve only the data you need.
|
|
|
|
|
I typically load only the master tables (those required by comboboxes throughout the app) as these are invariable quite small. I also load these asynchronously.
Rather than trying to use a progress bar (so 90s) I use a busy indicator.
Then each View/form/page loads only the content required. As Sledge pointed out this is called lazy loading (I suspect he also load the mater table as required)
Never underestimate the power of human stupidity
RAH
|
|
|
|
|
I studied many questions in this forum that related to this problem.but I couldn't solve my problem.can you help me?the error happens in the line which was indicated by "****"
private static DataGridView Firstdgv;
private static DataGridView Finaldgv = new DataGridView();
private static List<string> SelectedColumns = new List<string>();
private static List<string> AvailableColumns = new List<string>();
public void Print_DataGridView(DataGridView dgv1)
{
PrintPreviewDialog ppvw;
try
{
Firstdgv = dgv1;
AvailableColumns.Clear();
foreach (DataGridViewColumn c in Firstdgv.Columns)
{
if (!c.Visible) continue;
AvailableColumns.Add(c.HeaderText);
}
FrmPrintOptions dlg = new FrmPrintOptions(AvailableColumns);
if (dlg.ShowDialog() != DialogResult.OK) return;
PrintTitle = dlg.PrintTitle;
PrintAllRows = dlg.PrintAllRows;
FitToPageWidth = dlg.FitToPageWidth;
SelectedColumns = dlg.GetSelectedColumns();
ppvw = new PrintPreviewDialog();
Finaldgv.AutoGenerateColumns = false;
foreach (DataGridViewColumn GridCol in Firstdgv.Columns)
{
if (!GridCol.Visible) continue;
if (!SelectedColumns.Contains(GridCol.HeaderText)) continue;
Finaldgv.Columns.Add(GridCol); ****
}
DGVPrinter obj = new DGVPrinter();
obj.PrintPreviewDataGridView(Finaldgv);
}
catch (Exception ex)
{
MessageBox.Show(ex.Message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
}
}
|
|
|
|
|
Try:
Finaldgv.Columns.Add((DataGridViewColumn)GridCol.Clone());
"These people looked deep within my soul and assigned me a number based on the order in which I joined."
- Homer
|
|
|
|
|
thank you
It works
|
|
|
|
|
Dear friend now I have another problem.I want to know that how can I access to a column contents?
because "Gridcol" just returns columns header and in "Finaldgv" just columns header will be added. Actually I need each columns header text with its contents .
thank you.
|
|
|
|
|
I created a window with a field to set the name that the file will be saved. And with the code below I run inside the MainWindow.
var dialog = new windowFileName();
if (dialog.ShowDialog() == true)
{
MessageBox.Show(dialog.strFileName_str);
}
But I'm not getting check if the field is empty. I tried:
if (dialog.ShowDialog() == false)
{
MessageBox.Show("Please, enter the name file");
dialog.txtFileName.Focus();
}
But the dialog close and does not work.
|
|
|
|
|
juliogyn wrote: But the dialog close and does not work. Of course it does, because the tests you are making only happen after the ShowDialog() method returns. Check http://msdn.microsoft.com/en-us/library/c7ykbedk.aspx[^] for full details of how this operates. You need to trap the events that cause the dialog to be closed, and add your tests there to prevent it closing until the correct data is entered by the user.
Veni, vidi, abiit domum
|
|
|
|
|
Get the first day of the month and the last day of the month ?
Below is the error code
kptDTPickerTo.Format = DateTimePickerFormat.Short;
kptDTPickerTo.Value = "01/" + DateTime.Today.Month + "/" + DateTime.Today.Year;
kptDTPickerFrom.Value = DateTimePickerFormat.Short;
kptDTPickerFrom.Value = "01/" + DateTime.Today.AddMonths(1) + "/" + DateTime.Today.Year;
kptDTPickerFrom.Value = kptDTPickerFrom.Value - 1;
modified 10-Sep-13 5:09am.
|
|
|
|
|
Where is the error code and what is your question?
Veni, vidi, abiit domum
|
|
|
|
|
I think the "error code" actually means the "code that is wrong", and I'm pretty sure his question is "I haven't bothered to step through the code, so I don't know why it's wrong".
|
|
|
|
|
Well, there are a few problems I can potentially see here. The first being what happens if the date format isn't set so that the month forms the second part of this? Your logic will go out the window. Plus, surely you just need to simplify the end date bit by subtracting one from the first day of this month + 1 month. In other words, the logic in your to picker is wrong in that you are adding 1 month to today and then expecing the last day to somehow be found out just by subtracting 1.
|
|
|
|
|
In case you're still wondering how to find the last day in the month, all you need to do is use DateTime.DaysInMonth . This is a handy method that returns this information.
|
|
|
|
|
Nothing is wrong with this code, fellas. This approach is format, Culture independent.
I've used this kind of logic many many times and its very compact.
As is obvious to all, 1st of a month is never a problem because all months have 1st.
Instead of writing yet another variant in C++/C# for "30 days hath sep...", simply add 1 to month to the variable you had for 1st of month, and then subtract 1 day from the Resulting date.
It is meant to done in date arithmetic with valid values in Date's class.
|
|
|
|
|
|
Why the default color green is not changed for progress bar control even though if change the forecolor property value to something else.it is always green by default.
|
|
|
|