|
Hi
I think it will reset the first record of the dropdownlist, when ever you load or refresh the datagridview.
if i am correct.
you need to set the selected index of a dropdownlist in row binding event of the datagridview.
i can suggest...
or use text box along with dropdownlist.
or lable along with dropdownlist
so just show the dropdownlist box only at the click of a cell.
and after selection hide the ddl and show the lable
|
|
|
|
|
Hi,
Thanks for your reply. I am copying here the code..bcoz I have already bound the dropdownbox but when i am selecting value it's get blank.
private void GetAnalysisitem()
{
using (new SessionScope(FlushAction.Never))
l_Analysisitem = ANALYSISITEM.FindAll();
if (l_Analysisitem != null)
{
DataSet ds = new DataSet();
TAnalysisitem = CastleUtil.ConvToDataTable(l_Analysisitem);
TAnalysisitem.TableName = "ANALYSISITEM";
TAnalysisitem.AcceptChanges();
ds.Tables.Add(TAnalysisitem);
// attach the dropdown to the categories column
this.c1TrueDBGrid2.Columns["MATERIAL"].DropDown = this.c1TrueDBDropdown1;
// underlying datasource value is ID
this.c1TrueDBDropdown1.DataField = "ID";
// display value will be Name
this.c1TrueDBDropdown1.ListField = "NAME";
// tell the grid that we're translating values
this.c1TrueDBGrid2.Columns["MATERIAL"].ValueItems.Translate = true;
// now use the dropdown to perform the translation for us
// using a more readable format (i.e.,"Name")
this.c1TrueDBDropdown1.ValueTranslate = true;
aNALYSISITEMBindingSource.DataSource = l_Analysisitem;
c1TrueDBGrid2.SetDataBinding(ds, "ANALYSISITEM", true);
}
TAnalysisitem.RowChanged += new DataRowChangeEventHandler(TAnalysisitem_RowChanged);
TAnalysisitem.RowDeleted += new DataRowChangeEventHandler(TAnalysisitem_RowChanged);
}
Thanks,
|
|
|
|
|
Hey have look at this....
protected void gvFV_RowDataBound(object sender, GridViewRowEventArgs e)
{
if (e.Row.RowIndex >= 0)
{
DropDownList ddlC = (DropDownList)e.Row.Cells[0].FindControl("ddlC");
}
}
this will bind the values to the each ddl in each cell
so that you cant get the blank ddl.
just try it out...
if you dont get me still... let me know it...
|
|
|
|
|
Hi everybody,
I'm new for the codeproject team, I think you will understand, and I promise to contribute as much as I could. My first question is concerned about playing mediaplayers using the csharp (c#) language. I have got a code that can possibly play medias, for e.g (videos), but when I compile it using visual studio 2008, it configures out that there is no a namespace called "axmediaplayer". I think it is possible to embed this namespace in the code as a library (class) by referencing it. So my question is I don't know how to embed it, or even I don't know where to find it. If there is a need to see the code I can post it later on.
Thank you for your cooperation.
modified on Wednesday, September 2, 2009 5:42 AM
|
|
|
|
|
|
|
This works....
namespace Test
{
public class MyPicturebox : System.Windows.Forms.PictureBox
{
public delegate void ImageChanged ( Object sender, EventArgs e );
public event ImageChanged OnImageChange;
public new Image Image
{
get { return base.Image; }
set
{
base.Image = value;
if (OnImageChange != null)
{
OnImageChange(this, new EventArgs());
}
}
}
}
public partial class Form1 : Form
{
public Form1 ( )
{
InitializeComponent();
PictureBox _PB = new PictureBox();
}
}
}
The only programmers that are better C# programmers, are those who look like this -> |
Programm3r
My Blog: ^_^
|
|
|
|
|
' This picturebox has BeforeImageChanged and AfterImageChanged events.
' Taken from http://thedotnet.com/nntp/96040/showpost.aspx
'
Imports System
Imports System.Windows.Forms
Imports System.Drawing
'
Public Class MyPictureBox
Inherits PictureBox
Private _image As System.Drawing.Image = Nothing
Public Event BeforeImageChanged(ByVal sender As Object, ByVal e As EventArgsImageChanged)
Public Event AfterImageChanged(ByVal sender As Object, ByVal e As EventArgsImageChanged)
Public Shadows Property Image() As Image
Get
Return _image
End Get
Set(ByVal Value As Image)
If Not Value Is _image Then
If Me.DesignMode Then
MyBase.Image = Value
_image = Value
Else
Dim ea As New EventArgsImageChanged
If _image IsNot Nothing Then
RaiseEvent BeforeImageChanged(Me, ea)
If ea.Cancel Then
Exit Property
End If
End If
MyBase.Image = Value
_image = Value
RaiseEvent AfterImageChanged(Me, ea)
End If
End If
End Set
End Property
End Class
Public Class EventArgsImageChanged
Inherits EventArgs
Private _cancel As Boolean = False
Public Property Cancel() As Boolean
Get
Return _cancel
End Get
Set(ByVal Value As Boolean)
_cancel = Value
End Set
End Property
End Class
|
|
|
|
|
I have a simple file naming app, and what I would like it to do is: When the user 'pastes' the clipboard text, update the clipboard with the next item.
So I knew I had to recieve messages which I've got to work. But the problem is my app only gets WM_DRAWINGCLIPBOARD, which doesn't seem right (its to 'early' in the cycle).
I think the problem is that I need to respond to messages sent to the other app (explorer), but I'm not sure how to do that in c#.
Failing that, what's the best way for an app to respond to a global key press? i.e. whatever app has focus, when the user press X do this.
|
|
|
|
|
cjb110 wrote: Failing that, what's the best way for an app to respond to a global key press? i.e. whatever app has focus, when the user press X do this.
You should create keyboard hook to handle that.
To capture copy,paste, ... you could use WM_COPY,WM_PASTE and etc.
Life is a stage and we are all actors!
|
|
|
|
|
I started with WM_Paste, but my app never receives that message, only WM_DrawingClipboard. I think because its not the target of the paste.
I'm think the global key press is probably more 'safe' in the long term.
|
|
|
|
|
cjb110 wrote: I started with WM_Paste, but my app never receives that message, only WM_DrawingClipboard. I think because its not the target of the paste.
Have you read WM_PASTE documentation first?
You cannot receive it into Form.WndProc because it's sended to some editable controls only.For example:
public class MyTextBox :TextBox
{
const int WM_PASTE = 0x302;
protected override void WndProc(ref Message m)
{
if (m.Msg ==WM_PASTE)
{
MessageBox.Show("WM_PASTE was fired");
}
base.WndProc(ref m);
}
}
Life is a stage and we are all actors!
|
|
|
|
|
Sorry, that's what I meant. I understood that the WM_PASTE gets sent to the target, and I know my app isn't the target!
What I hoped was possible, was that I could respond to the general message being sent to any target.
I'm going to look further into WM_DrawClipboard, as you seem to get two of those every time paste occurs, couldn't see any thing in msg, but I'm hoping one is sent before the 'pasting' occurs, and the other when its finished.
|
|
|
|
|
But the problem is my app only gets WM_DRAWINGCLIPBOARD, which doesn't seem right (its to 'early' in the cycle).
what is the wrong with this...
clipboard activity data can be handled only through WM_DRAWINGCLIPBOARD only.
|
|
|
|
|
I am writing a multithreaded application. A download manager to be precise. When downloading one file, everything is quite fine. The thread starts, downloads the file and terminates as expected. When i start another download thread, however, when the first is still running, i get the error above 9in the subject). The problem is on this line of code which is meant to create a new filestream and write the retrieved data to the stream.
strLocal = new FileStream(Application.StartupPath+"\\"+SaveAsTextBox.Text,FileMode.Create, FileAccess.Write,FileShare.ReadWrite);
The download method is called Download(), is void and does not take any arguments.
A thread is started using
DownloadThread[j] = new Thread(new ThreadStart(Download));<br />
DownloadThread[j].Start();
where j has a value incremented per click, so as to start a new thread each time.
What i do not understand is that the exception seems to suggest that 2 write operations are requesting to be handled by the same stream, yet it is actually a different stream because the user changes the SaveAsTextBox.Text on every new download.
Any answers?
BHM
|
|
|
|
|
Sounds like you're trying to write to the same file on two threads ? That plainly won't work.
Christian Graus
Driven to the arms of OSX by Vista.
Read my blog to find out how I've worked around bugs in Microsoft tools and frameworks.
|
|
|
|
|
What is the actual value of "SaveAsTextBox.Text" in each of the threads?
|
|
|
|
|
for each of the threads, it is different. say AAA.avi for one and BBB.avi for another. The two are meant to be written to the same forlder nonetheless.
BHM
|
|
|
|
|
Maximus Byamukama wrote: say AAA.avi for one and BBB.avi for another. The two are meant to be written to the same forlder nonetheless.
Yes, but what are the actual values? Have you checked the filenames in both threads at execution time?
|
|
|
|
|
Hello,
i want to make an application, which runs in the background. But maybe not a service, because i maybe let it run under mono and under linux. And i had a few problems, to start the service...
But now the problem, how can i let my application run in the background? I don't want, that it close itself if it's finished with the "Main-Method", because i have a few events and connections which listen on some ports.
I think it should work with
while(true)
{
}
but doesn't such a loop need a lot of resources??
Thanks
|
|
|
|
|
Hi,
I would do the following. Within the Main-Method start a thread to do the main-work (whatever your application should do). After you started the thread, use a Console.ReadLine() to wait for user-input to stop the application.
It should look like this:
public static void Main(string[] args) {
while(true) {
string input = Console.In.ReadLine();
if("stop".Equals(input)) {
break;
}
}
}
Regards
Sebastian
|
|
|
|
|
Does this make sense, what else can a console app do at this point except sit there looking black.
|
|
|
|
|
Well as already mentioned the console app could run like a service. For example like starting Apache Tomcat in console etc.
|
|
|
|
|
|
You could use a ManualResetEvent:
public static ManualResetEvent stopEvt = new ManualResetEvent(false);
static void Main(string[] args)
{
stopEvt.WaitOne();
}
Then, in your listening thread you can use stopEvt.Set(); to close the application.
|
|
|
|