|
Hi,
In my datagridview, if I click on a cell, the entire cell is getting selected. Instead, I'm trying to select the value in the cell. Can you guide me to get this.
Thanks and Regards,
Lalitha.
|
|
|
|
|
|
0bx wrote: In the designview
Where did the OP mention anything about design view?
0bx wrote: Changing the values in the gridview
The OP asked for highlighting, not editing.
Please read the question thoroughly before commenting
I know the language. I've read a book. - _Madmatt
|
|
|
|
|
MSDN?...[^]
Rhys
"I'd rather die on my feet than live on my knees"
|
|
|
|
|
Hello,
you can try handling the events or CellClick CellContentClick and manage your DataGridView EditMode property as follows.
private void dataGridView1_CellContentClick(object sender, DataGridViewCellEventArgs e)
{
dataGridView1.EditMode = DataGridViewEditMode.EditProgrammatically;
dataGridView1.BeginEdit(true);
}
private void dataGridView1_CellClick(object sender, DataGridViewCellEventArgs e)
{
dataGridView1.EditMode = DataGridViewEditMode.EditProgrammatically;
dataGridView1.BeginEdit(true);
}
Then you have to manage one of these two events, the one that best suits your needs.
Bye
Carmelo La Monica
|
|
|
|
|
Hi,
I have a datatable from which i am exporting the results to Excel file.The exporting happens perfectly....But web page is not getting loaded completely.Its because of the Response.End();.It terminates the execution of the page further.
Because I have some other code after Response.End(); to get executed and needs to be displayed in the page.Is there a way to get the complete execution of the page.I am struck with this problem for while now..........Any help is appreciated.
DataTable dtMemberList = LinqToDatatable.LinqToDataTable(MembersList);
string attachment = "attachment; filename=Search.xls";
Response.ClearContent();
Response.AddHeader("content-disposition", attachment);
Response.ContentType = "application/vnd.ms-excel";
Response.Write("\n");
Response.Write("Search Results");
Response.Write("\n");
string tab = "";
Response.Write(tab + "Member ID");
tab = "\t";
Response.Write(tab + "Memberdoc Received Date");
tab = "\t";
Response.Write(tab + "Memberdoc Import Date");
tab = "\t";
Response.Write(tab + "Memberdoc Status");
tab = "\t";
Response.Write(tab + "Memberdoc Type");
Response.Write("\n");
int i;
foreach (DataRow dr in dtMemberList.Rows)
{
tab = "";
for (i = 0; i < dtMemberList.Columns.Count; i++)
{
Response.Write(tab + dr[i].ToString());
tab = "\t";
}
Response.Write("\n");
}
Response.End();
|
|
|
|
|
DON'T cross post. Read the forum guidelines. Choose one forum and use it.
I know the language. I've read a book. - _Madmatt
|
|
|
|
|
What he said, and learn to use the pre tags.
|
|
|
|
|
How connecting to a database (MS SQL) by the c# code and not by the form guide?
I hope you manage to understand the question ...
greetings,
Dread
|
|
|
|
|
Using a <a href="http://msdn.microsoft.com/en-us/library/system.data.sqlclient.sqlconnection.aspx">SqlConnection</a>[<a href="http://msdn.microsoft.com/en-us/library/system.data.sqlclient.sqlconnection.aspx" target="_blank" title="New Window">^</a>] object. There's an example at the bottom of the page.
Bastard Programmer from Hell
|
|
|
|
|
You need to use ADO.Net directly in your code.
Setup a connection and then execute query using a command.
The funniest thing about this particular signature is that by the time you realise it doesn't say anything it's too late to stop reading it.
|
|
|
|
|
|
|
|
I have problem. I can' identify my mistake...
int dt = Convert.ToInt32(Items.Rows[T1]["F14"].ToString().Trim());
int mn = Convert.ToInt32(Items.Rows[T1]["F15"].ToString().Trim());
int yr= Convert.ToInt32(Items.Rows[T1]["F16"].ToString().Trim());
string DtString =mn.ToString().Trim() +"/"+ dt.ToString().Trim()+"/"+ yr.ToString().Trim();
DateTime RegExp = Convert.ToDateTime(DtString);
exp_date is datetime field in sqlserver.
string MyDtQry = "UPDATE MyTable SET exp_date='" + RegExp + "' where MyTable.id_no='" + AlmIDNo + "'";
I can't Identify the mistake
Thanks For Ideas
|
|
|
|
|
You have two mistakes
The first is not properly formatting your code as per the posting guidelines.
The second is not saying what errors or difficulties you are encountering.
I know the language. I've read a book. - _Madmatt
|
|
|
|
|
Paramu1973 wrote:
string MyDtQry = "UPDATE MyTable SET exp_date='" + RegExp + "' where MyTable.id_no='" + AlmIDNo + "'";
In the above statement you need to check what value is being returned by RegExp and that it is in the correct format for both the SQL statement, and your regional date settings. I have a feeling that there are better ways to do this by using SQL parameters which accept DateTime s as values rather than strings.
The best things in life are not things.
|
|
|
|
|
why not use the ctor for DateTime(int year, int month, int day)?
Somthing like:
DateTime dt = new DateTime(yr,mm,dd)
Note that the code above, is written directly in here. Not sure if it will compile but I know that there is such a way to create a DateTime instance.
[add] Also add a parameter. Don't pass the datetime as string(varchar in SQL using '') if the field is datetime in sql.
The same for ID. Don't pass it as string/varchar type if it's int/long.
Something like this:
string MyDtQry = "UPDATE MyTable SET exp_date=@dt where MyTable.id_no=@id";
cmd.Parameters.AddWithVAlue("@dt", RegExp);
cmd.Parameters.AddWithVAlue("@id", AlmIDNo);
All the best,
Dan
modified on Thursday, July 7, 2011 11:55 AM
|
|
|
|
|
1. Instead of going through strings to construct an instance of DateTime , you should use the corresponding constructor: new DateTime(yr, mn, dt)
2. Instead of building a SQL string with embedded values, use parameterized SQL[^]: it makes your code more robust, not to mention considerable performance gains.
|
|
|
|
|
What datatypes are in the table fields? If they're Int32, just cast them. Don't convert to string and right back again.
And don't use the Convert class, it's needless, just use the methods of the datatypes Int32.Parse etc.
You can only pass a DateTime value direectly to SQL with a parameter (which is the right way to do it anyway).
|
|
|
|
|
Try it this way:
DateTime RegExp = new DateTime(0);
try
{
RegExp = new DateTime(yr, mn, dt);
string dateStr = string.Format("{0}/{1}/{2}", yr, mn, dt);
bool parsed = DateTime.TryParse(dateStr, out RegExp);
if (parsed)
{
}
else
{
error
}
}
catch (Exception ex)
{
}
".45 ACP - because shooting twice is just silly" - JSOP, 2010 ----- You can never have too much ammo - unless you're swimming, or on fire. - JSOP, 2010 ----- "Why don't you tie a kerosene-soaked rag around your ankles so the ants won't climb up and eat your candy ass." - Dale Earnhardt, 1997
|
|
|
|
|
I want to create a list/dictionary of all the friendly application names and their executable paths & commands for a specific file type. I've used AssocQueryString but it only returns one instance value.
For example:
The file type ".cs" on my PC has got many application associations for it when I right-click on a ".cs" file and select "Open With->" in the context menu, like "Microsoft Visual Studio 2008" & "Microsoft Visual Studio 2010" & "Notepad" & "Wordpad".
How can I enumerate all these values into a list in C#, obviously it must be extracted from the registry, but I'm very lost in all the "OpenWithList" and "OpenWithProgids" keys..
Thanks
|
|
|
|
|
|
By default selecting an item in a list view with large icon mode makes the selected item thumb grayish.
How to provide thumbnail selection display as in windows explorer?
9ine
|
|
|
|
|
What viewing setting in windows explorer are you referring to? There are five of them in windows xp's explorer.
Ciao,
luker
|
|
|
|