|
Hi,
I have a TextBox, and DataGrid on a form. TextBox has the focus, by pressing the PageDown key while in TextBox, I want the DataGrid to perform the PageDown functionality.
I know that I have to use SendMessage method, I am just no sure what parameters I have to pass for the Pagedown handler.
Any ideas?
Thank you.
|
|
|
|
|
For simplicities sake I have extracted the following example from a larger app.
I have a simple form that has a listBox (L1) and two textBoxes (T1 & T2) and a submit button (B1). I have created a dataset(D1) that currently only has one table(T1) in it. I use VS's designer to bind the contents of T1 to L1. I then use the Databindings properties of the textBoxes to respectively bind one of the columns of the table (T1) to each. This works fine. It allows me to select an item from L1 and the text in the textboxes change to reflect their respective columns.
Now I added a function to hadle the SelectedIndexChanged event of L1. For the sake of simplicity I just put a MessageBox in the function. When I change the text in one of the textboxes then click the B1 button I have a function that ends the current edit and updates the tableAdapter. The value gets updated in the db. Then something unexpected happens after the update. The SelectedIndexChanged event fires once for every row in DS.T1 (Maybe as the listBox refreshes). Should this happen? I thought the SelectedIndexChanged event only fired when a user clicks on an item in the listbox.
How can I get the SelectedIndexChanged event to only fire when an item in the listbox is clicked?
BTW - I am using VS2008b2
-Kevin
-- modified at 16:11 Wednesday 12th September, 2007
|
|
|
|
|
the question are:
i add this into a listview
string ett = "1";
string u = comboBox1.Text;
string q = textBox1.Text;
string w = textBox2.Text;
DateTime dt = DateTime.Now;
if (q.Length > 0 && w.Length > 0 && u.Length > 0)
{
if (this != null)
{
string time = dt.ToString("dd");
string name = this.textBox1.Text + time.ToString() + ett;
ListViewItem item = new ListViewItem(new string[] { u, name, dt.ToString(), this.textBox2.Text });
ListViewIns.Items.Add(item);
But string u and name can not be equal with something else in a .txt file
for example
string u = Online
name = k431121
And the .txt file look like this:
#
online
k431121
blah
blah
If they two string match with line[index +1] an line[index +2] then add +1 on k431121. So in this example they match it will add +1 and look like this
#
online
k431121
blah
blah
#
online
k431122
blah
blah
I have a code but it don´t want to work:
private List<string> Entries;
private void LoadEntries()
{
string key;
Entries=new List<string>();
foreach (ListViewItem item in listView1.Items)
{
key = string.Concat(item.SubItems[0], "@@", item.SubItems[1]);
if (!Entries.Contains(key))
Entries.Add(key);
}
}
private void PopulateListView(List<string> list)
{
LoadEntries();
listView1.View = View.Details;
listView1.Columns.Add("Kolumn1");
listView1.Columns.Add("Kolumn2");
listView1.Columns.Add("Kolumn3");
listView1.Columns.Add("Kolumn4");
listView1.Columns.Add("Kolumn5");
string Name,No,key;
int n;
for (int i = 0; i < list.Count; i += 5)
{
Name = list[i+1];
No = list[i + 2];
while(Entries.Contains(key = string.Concat(Name, "@@", No)))
{
n = Convert.ToInt32(No.Substring(No.Length - 1));
No = String.Concat(No.Substring(0, No.Length - 1), n + 1);
}
if (!Entries.Contains(key))
Entries.Add(key);
ListViewItem item = new ListViewItem(list[i]);
item.SubItems.Add(Name);
item.SubItems.Add(No);
item.SubItems.Add(list[i + 3]);
item.SubItems.Add(list[i + 4]);
listView1.Items.Add(item);
}
}
My question is: can you help me build this together..???
Thanks////
|
|
|
|
|
Can somebody give me a sample of GridView update? I dont want to update each row. Instead, I want to store all updates on the client side(using datatable)
and update the entire gridview checking if the records are different from the existing database. For update command, am using SQL stored proc.
Please give me a sample.
Thanks
|
|
|
|
|
You can use TableAdapter.Fill() Method to update DataGridView, assuming that DataGridView is bound to dataset, and it has BindingSource and TableAdapter.
|
|
|
|
|
as the subject,
I want to add hyperlink to datagridview column, the link can download pdf file, like IE effect.
looks a little bit hard?
if can leave me a demo code to download is a prefer.
god bless me,
tomorrow is my task deadline.
thanks a lot,
James Liu
|
|
|
|
|
liujw wrote: I want to add hyperlink to datagridview column, the link can download pdf file, like IE effect.
DataGridViewLinkColumn, DataGridViewLinkCell are the types you should look into.
liujw wrote: god bless me,
tomorrow is my task deadline.
That's a great quote.
|
|
|
|
|
Yeah, that question was worth a '5'
liujw wrote: tomorrow is my task deadline
liujw wrote: if can leave me a demo code to download is a prefer.
"More functions should disregard input values and just return 12. It would make life easier." - comment posted on WTF
"I haven't spoken to my wife now for 48 hours. I don't like to interrupt her.
|
|
|
|
|
Hi Everyone
I need a help, i have a number for eg :- 9.5 i want it to be 9.05 while taking to database cause if use round of it will give 9.50 but i want 9.05. am using C# 2005.
Thanks In Advance
|
|
|
|
|
rowdykuttan wrote:
I need a help, i have a number for eg :- 9.5 i want it to be 9.05 while taking to database cause if use round of it will give 9.50 but i want 9.05. am using C# 2005.
Can you rephrase what you are trying to accomplish? Not sure I follow.
It isn't enough to do well in life.
One must do good when and where one can.
Otherwise, what's the point?
|
|
|
|
|
It seems that he wants to redefine how mathematics works.
Deja View - the feeling that you've seen this post before.
|
|
|
|
|
|
Pete O`Hanlon wrote: It seems that he wants to redefine how mathematics works.
Thanks for the chuckle - that might just be the case.
I wanted to give the author the benefit that it might just be a language issue, though.
It isn't enough to do well in life.
One must do good when and where one can.
Otherwise, what's the point?
|
|
|
|
|
double answer;
if(dbNumber == 9.5)
{
answer = 9.05;
return answer;
}
Why is common sense not common?
Never argue with an idiot. They will drag you down to their level where they are an expert.
Sometimes it takes a lot of work to be lazy
The people in the lounge said I should google for the answer to a programming question but I do not know what search engine to use
|
|
|
|
|
ROTFL !!!!
Christian Graus - Microsoft MVP - C++
"I am working on a project that will convert a FORTRAN code to corresponding C++ code.I am not aware of FORTRAN syntax" ( spotted in the C++/CLI forum )
|
|
|
|
|
Hi,
Try using this
double d = 9.5;<br />
d = Math.Floor(d) + ((Math.Floor(d) + 1) - d) / 10;<br />
Paras Kaneriya The difference between genius and stupidity is that genius has its limits.
|
|
|
|
|
Hi
I've been searching through multiple articles on this topic,
however,
what I'm not finding is a simple way to count decimals. I simply want to count
how many decimals are in the string, unfortunately everything in regex seems to involve
replacing the decimals...and regex seems really heavy way of doing something that should
be simple.
Any thoughts on this topic?
-----------------------------------------------------------
Completion Deadline: two days before the day after tomorrow
|
|
|
|
|
jgasm wrote: I simply want to count
how many decimals are in the string, unfortunately everything in regex seems to involve
replacing the decimals...and regex seems really heavy way of doing something that should
be simple.
If you know the string always has a decimal:
Int32 decimalCount = text.Split('.')[1].Length
If it doesn't always have a decimal, it gets much more complicated :
Int32 decimalCount = text.IndexOf('.') > -1 ? text.Split('.')[1].Length : 0;
Share and enjoy.
Sean
|
|
|
|
|
Count significant decimal places? This is rather rough:
[System.STAThreadAttribute]
static void Main(string[] args)
{
int d ;
args [ 0 ] = args [ 0 ].Trim( new char[] { '0' } ) ;
d = args [ 0 ].IndexOf ( '.' ) ;
if ( d >= 0 )
{
d = args [ 0 ].Length - d - 1 ;
}
else
{
d = 0 ;
}
System.Console.WriteLine ( d ) ;
}
|
|
|
|
|
Thank you so much for the reply.
However, Sean's answer was exactly what I was looking for.
-----------------------------------------------------------
Completion Deadline: two days before the day after tomorrow
|
|
|
|
|
If you don't need the results of the Split for something else then mine is likely more efficient.
Here it is with the Conditional Operator:
int d ;
args [ 0 ] = args [ 0 ].Trim( new char[] { '0' } ) ;
System.Console.WriteLine
(
( d = args [ 0 ].IndexOf ( '.' ) ) == -1 ? 0 : args [ 0 ].Length - d - 1
) ;
|
|
|
|
|
A similar question was asked in the microsoft.public.dotnet.languages.vb newsgroup two days ago. Here's the code that I suggested, converted to C#, and assuming that the decimal separator is a period:
int pos = text.IndexOf('.');
int decimalCount;
if (pos == -1) {
decimalCount = 0;
} else {
decimalCount = value.Length - pos - 1;
}
It's about ten times faster than splitting the string.
If you want it in few lines:
int pos = text.IndexOf('.');
int decimalCount = (pos == -1) ? 0 : value.Length - pos - 1;
---
single minded; short sighted; long gone;
|
|
|
|
|
Hello All,
My Problem Is I Have A Ledger Which Have Values Like:
jan feb mar april may june july...... dec
Ajay 0 1 2 0 10 8
Anu 0 55 54 88 45 77 ......
...
..
Now These are marks of students in a particular subject for everymonth
Teacher has to enter these marks in the matrix way as i shown above.
I m Unable to FInd ne such control in asp.net
Editable grid doesnt work for me. as i cant fill any garbage data in any table.
Any suggestions? I m in terrible situaton.
Please Help me.
(I m A Novice)
Thanks To ALL
Sanchit Jain
|
|
|
|
|
If the only thing preventing you from using the standard grid is that any old garbage data can be put in it, why not do some client-side or server-side validation of the data?
p.s. this question might be better asked in the ASP.NET forum.
|
|
|
|
|
hi all,
is there a(ny) way to check whether a cell value is empty or not ?
when i try to do (for an empty cell): string.isnullorempty(datagridview.rows[i].cells[j].value.tostring());
i get this error: object reference not set to an instance of an object.
i'd like to know if there is any solution for my problem.
thanks in advance.
MFA
|
|
|
|