|
I have an application running on a PDA that currently uses the OnClick Event of a DataGrid to perfortm some functionality. I would like to have the same functionality run when the current row of my DataGrid is highlighted (by the user scrolling ro it instead of clicking on it). The method to use would seem to be OnSelectedIndexChanged but this does not seem to be available in the Compact Framework (3.5). I The OnGotFocus doesn't seem to be suitable either (I guesss that this is because it applies to the DataGrid itself and not the row). Can anyone suggest how I can get this to work. Note that I only want the event to fire when the user moves to the row and not when the grid is populated.
Thanks
|
|
|
|
|
Just use the Mouse or Click Events exposed by the datagrid.
and get its CurrentRowIndex. You may have to bind the datagrid datasource using the CurrencyManager.
Then just build a DataRowView from it.
I'm not sure if this is what you are asking.
BTW. you should post this in Mobile Development.
Regards
M Curley.
|
|
|
|
|
The problem is that I will not be clicking on the grid so the onClick event won't fire. I will just be using the button thing at the bottom of the PDA ro scroll down the list. I was looking for an event that would fire when the row was highlighted. The SelectedIndexChanged looked like the one for me but that doesn't seem to be available in the Compact Framework.
I will post this again on the Mobile Development board and make my question a bit clearer. Thanks for your reply anyway.
|
|
|
|
|
Create an integer variable.
Then load the datagrid and select the first row by using
dataGrid.Select(0)
Then capture the up and down keys on the form and increment or decrement
this variable and pass this to the dataGrid
dataGrid.Select(your_variable_here)
Would this not achieve what you want to do?
Regards
Mick Curley
|
|
|
|
|
I had a bho application developed in Vs2005 c#, I had made an msi setup, when I was trying to install
the setup, it is successfully getting installed, but the dll does not gets injected in the registry.
Why?
The registry path is "Software\\Microsoft\\Windows\\CurrentVersion\\Explorer\\Browser Helper Objects"
But this is succesfully injected in other Pc's
The .Net framework2.0 is present in all PC's
Code for registering and unregistering:
public static string BHOKEYNAME = "Software\\Microsoft\\Windows\\CurrentVersion\\Explorer\\Browser
Helper Objects";
[ComRegisterFunction]
public static void RegisterBHO(Type type)
{
RegistryKey key = Registry.LocalMachine.OpenSubKey(BHOKEYNAME, true);
if (key == null)
{
key = Registry.LocalMachine.CreateSubKey(BHOKEYNAME);
}
string guidString = type.GUID.ToString("B");
RegistryKey bhoKey = key.OpenSubKey(guidString, true);
if (bhoKey == null)
{
bhoKey = key.CreateSubKey(guidString);
}
// NoExplorer:dword = 1 prevents the BHO to be loaded by Explorer
string _name = "NoExplorer";
object _value = (object)1;
bhoKey.SetValue(_name, _value);
key.Close();
bhoKey.Close();
}
[ComUnregisterFunction]
public static void UnregisterBHO(Type type)
{
RegistryKey registryKey = Registry.LocalMachine.OpenSubKey(BHOKEYNAME, true);
string guid = type.GUID.ToString("B");
if (registryKey != null)
registryKey.DeleteSubKey(guid, false);
}
In some PC's the dll gets registered and in some PC's dll doe not gets registered
|
|
|
|
|
could not load file or assembly 'Microsoft.mshtml, version=7.0.3300.0,Culture=neutral,PublicKey=b03f5f7f11d50a3a' or one of its dependencies. The System cannot find the file specified.
|
|
|
|
|
I cannot figure out how to translate the following line of code:
int maxMagicBytesLength = imageFormatDecoders.Keys.OrderByDescending(x => x.Length).First().Length;
into equivalent .Net 2.0 (C# 2.0) code.
Here's the declaration of the imageFormatDecoders dictionary:
private static Dictionary<byte[], Func<BinaryReader, Size>> imageFormatDecoders = new Dictionary<byte[], Func<BinaryReader, Size>>()
{
{ new byte[] { 0x42, 0x4D }, DecodeBitmap },
{ new byte[] { 0x47, 0x49, 0x46, 0x38, 0x37, 0x61 }, DecodeGif },
{ new byte[] { 0x47, 0x49, 0x46, 0x38, 0x39, 0x61 }, DecodeGif },
{ new byte[] { 0x89, 0x50, 0x4E, 0x47, 0x0D, 0x0A, 0x1A, 0x0A }, DecodePng },
{ new byte[] { 0xff, 0xd8 }, DecodeJfif },
};
As my rest of the application is .net 2.0. I just can't figure out the use of the OrderByDescending() method. I've not worked in C# 3.0 or later versions. Please help me.
Thanks in advance.
Excuse me for buttin' in, but I'm interrupt driven.
|
|
|
|
|
Ankit Rajpoot wrote: OrderByDescending(x => x.Length).First().Length;
This code orders the collection from highest to lowest, based on the length, then grabs the first object. You could just iterate over the objects, and store the highest length.
Christian Graus
Driven to the arms of OSX by Vista.
Please read this[ ^] if you don't like the answer I gave to your question.
"! i don't exactly like or do programming and it only gives me a headache." - spotted in VB forums.
|
|
|
|
|
I want to type the special characters in C#.I don't know how to do that?Please help me.Thanks alot!!!!!
|
|
|
|
|
Do you mean how do you type them into the IDE ? The same way you did, you get them and paste them. There's a character map that gives you access.
Christian Graus
Driven to the arms of OSX by Vista.
Please read this[ ^] if you don't like the answer I gave to your question.
"! i don't exactly like or do programming and it only gives me a headache." - spotted in VB forums.
|
|
|
|
|
Greeting,
I use a datagridview control in my form(C#.net 2005) to monitor some data received.
I want the datagridview has autoscroll to show recent data received for the user.
Normally the user should scroll the datagridview
Regards
|
|
|
|
|
It can be achieved by setting the overflow style to scroll of the div tag.
<div style="overflow:scroll;width:40%;height:40%">
e.g.
The grid view in the .aspx is like this
<div style="overflow:scroll;width:30%;">
<asp:GridView ID="gvDetail" runat="server" AutoGenerateColumns="False"
HeaderStyle-BackColor="gray" AlternatingRowStyle-BackColor="GreenYellow "
BackColor="white" BorderColor="blue" BorderStyle="None" Width="80%">
<Columns>
<asp:BoundField DataField="UserId" HeaderText="User Id">
<ItemStyle HorizontalAlign="Left" Width="80%" />
</asp:BoundField>
<asp:BoundField DataField="Name" HeaderText="User Name">
<ItemStyle HorizontalAlign="Left" Width="80%" />
</asp:BoundField>
<asp:BoundField DataField="Age" HeaderText="User Age">
<ItemStyle HorizontalAlign="Left" Width="40%" />
</asp:BoundField>
<asp:BoundField DataField="Address" HeaderText="User Address">
<HeaderStyle Wrap="true"></HeaderStyle>
<ItemStyle HorizontalAlign="Left" Width="10%" Wrap="true" />
</asp:BoundField>
<asp:BoundField DataField="Sex" HeaderText="User Sex">
<ItemStyle HorizontalAlign="Left" Width="10%" />
</asp:BoundField>
<asp:BoundField DataField="DOB" HeaderText="User DOB">
<ItemStyle HorizontalAlign="Left" Width="10%" />
</asp:BoundField>
<asp:BoundField DataField="Year" HeaderText="User Year">
<ItemStyle HorizontalAlign="Left" Width="10%" />
</asp:BoundField>
</Columns>
</asp:GridView>
</div>
I have used a datatable as the grid source and bind to the grid in the Page_Load event
DataTable dtSource = new DataTable();
#region Data Table Creation
dtSource.Columns.Add("UserId");
dtSource.Columns.Add("Name");
dtSource.Columns.Add("Age");
dtSource.Columns.Add("Address");
dtSource.Columns.Add("Sex");
dtSource.Columns.Add("DOB");
dtSource.Columns.Add("Year");
#endregion
#region Add Rows
dtSource.Rows.Add("1", "nil1", "23", "aaaayyyyy", "male", "29/12/3456", "2345");
dtSource.Rows.Add("2", "nil2", "23", "aaaa", "male", "29/12/3456", "2345");
dtSource.Rows.Add("3", "nil3", "23", "aaaa", "male", "29/12/3456", "2345");
dtSource.Rows.Add("4", "nil4", "23", "aaaa", "male", "29/12/3456", "2345");
dtSource.Rows.Add("5", "nil5", "23", "aaaa9999", "male", "29/12/3456", "2345");
dtSource.Rows.Add("6", "nil6", "23", "aaaa", "male", "29/12/3456", "2345");
dtSource.Rows.Add("7", "nil7", "23", "aaaa", "male", "29/12/3456", "2345");
dtSource.Rows.Add("8", "nil8", "23", "aaaa", "male", "29/12/3456", "2345");
dtSource.Rows.Add("9", "nil9", "23", "aaaa", "male", "29/12/3456", "2345");
dtSource.Rows.Add("10", "nil10", "23", "aaaa", "male", "29/12/3456", "2345");
#endregion
gvDetail.DataSource = dtSource;
gvDetail.DataBind();
Hope this helps
Niladri Biswas
|
|
|
|
|
This is not the ASP.NET forum.
Christian Graus
Driven to the arms of OSX by Vista.
Please read this[ ^] if you don't like the answer I gave to your question.
"! i don't exactly like or do programming and it only gives me a headache." - spotted in VB forums.
|
|
|
|
|
|
Hi
I have the code below wich copies a database to the same server with a different name, but the Database Diagram isn't copied. I need it because of the relationship between tables, primary keys,
foreign keys, delete rules and update rules as cascade. I have googled but
haven't found anything that works. I found this code, 'insert into
B.dbo.sysdiagrams select [name], principal_id, version,definition from
A.dbo.sysdiagrams', but the sysdiagrams isn't copied to the database when
I'm running the code below. And before when I ran the code below I didn't
get any errors, but now I get the error errorCode=-1073548784. Although the
error the database is created but without the Database Diagram, the
sysdiagram. If anybody have a solution to this problem, please help me. I'm
using SQL Server 2008.
Transfer transfer = new Transfer(server.Databases["Questions"]);
transfer.CopyAllObjects = true;
transfer.CopyAllUsers = true;
transfer.CopyAllTables = true;
transfer.Options.WithDependencies = true;
transfer.Options.NoIdentities = false;
transfer.DestinationDatabase = newdb.Name;
transfer.DestinationServer = server.Name;
transfer.DestinationLoginSecure = true;
transfer.CopySchema = true;
transfer.CopyData = true;
transfer.Options.DriAllKeys = true;
transfer.CopyAllStoredProcedures = true;
transfer.Options.ContinueScriptingOnError = true;
transfer.TransferData();
Fia
|
|
|
|
|
I am wondering is it possbile to use a VB based control in C# in Visual Studio?
if so, is there any difference between c# based control in C#?
thanks
|
|
|
|
|
1. yes
2. no
DaveBTW, in software, hope and pray is not a viable strategy. (Luc Pattyn) Visual Basic is not used by normal people so we're not covering it here. (Uncyclopedia) Why are you using VB6? Do you hate yourself? (Christian Graus)
|
|
|
|
|
Just to expand on the previous poster's points:
All .Net Framework base languages are compiled down to a bytecode concoction known as MSIL or CIL
MSIL: Microsoft Intermediate Language
CIL: Common Intermediate Language
MSIL was what CIL was called back when the .Net Framework was in Beta
A VB.Net based control is converted to code behind the scenes by the IDE (Visual Studio or SharpDevelop, etc.) This code is then converted to CIL at compile time and interpreted by the .Net Framework's JIT (Just In Time) compiler into actual processor code at runtime. This means that languages using the .Net Framework are known as interpreted languages (which means they use a bytecode which is converted to processor code at runtime), as opposed to compiled languages (which produce processor code from the first base) like C++. This is why C++ and ASM is usually faster than C# and VB.Net
Anyway, the upshot of this commonly-compiled basecode is that the same code will compile down to the same bytecode, regardless of which language you write it in. This makes up half of a .Net Framework executable (assembly). Logically then, the metadata (the other half of an assembly) would also be the same. Therefore, we can say that if an algorithm is implemented identically in two .Net Framework languages, they will produce an identical output. So if you can add a reference to and use a VB-based control, you can also add a reference to and use a C#-based control. To all intents and purposes, they are identical
Between the idea
And the reality
Between the motion
And the act
Falls the Shadow
|
|
|
|
|
thank you for your detailed exaplaination.
Can I understand that .net languages (VB,c# and c++) are actually the combination of compilation and interpretation languages. because they are neither same as conventional pure complied language nor the pure interpretated languages. But it seems that c# is said always as complied language, does this mean that c# itself belong to compilation language but when it is used in .net framwork, it contains one part of interpretation process. or my understanding is wrong?
thanks again.
|
|
|
|
|
All languages that target the .NET CLR are compiled. There is no interpretative portion.
|
|
|
|
|
Odd; I remembered reading somewhere that the languages are interpreted. Are they compiled to bytecode and then JIT-interpreted into machine code at runtime by the framework?
Between the idea
And the reality
Between the motion
And the act
Falls the Shadow
|
|
|
|
|
That's just a non-common way to say it. Usually they say JIT-compiled. Which is more like what it does, since it takes the MSIL and compiles it (but at runtime, hence the "JIT")
Unless you use NGEN of course, then it's just compiled (not at runtime).
But anyway, the language itself (the syntax) doesn't mandate anything. You could take C# source and compile it straight down to native code. Several compilers which do exactly that are already available, but you usually lose something - such as the ability to use reflection or interoperability with .NET assemblies.
And that goes the other way too, one could write an interpreter for it. That's mostly useless though, why would you want to execute the program slow on purpose? It would usually be faster to compile it on the fly..
|
|
|
|
|
thanks, but from previous answers, it seems to me there are interpretation parts.
I am still not very clear. It is necessary to clarify this conecpt.
|
|
|
|
|
MSIL is the virtual assembly code for the CLR. It's comparable to Java's intermediary code. Both are not usually used except when disassembling. Usually the binary form (aka byte code) is used, which is what goes inside the assemblies.
The JIT compiler then reads the byte code and turns it (with some very complicated steps) into native x86 (or x64 or even Itanium2) code, and then lets the CPU run that.
|
|
|
|
|
Glad to disappoint - there is no interpretation going on at all.
|
|
|
|
|