Jump to content
Xtreme .Net Talk

bufer24

Members
  • Posts

    14
  • Joined

  • Last visited

About bufer24

  • Birthday 04/05/1980

bufer24's Achievements

Newbie

Newbie (1/14)

0

Reputation

  1. The goal is to use the empty space for some other controls. I could add for example a button to the grid like this: MyGrid.Controls.Add(MyButton). The reason I am looking for this kind of solution is that I don´t want to put the datagrid into a usercontrol and then expose the column collection using some extensive code (i.e. writing my own columncollection editor and who knows what else). I still want the control to behave mainly as datagridview.
  2. Yes, I want the listbox to be OwnerDrawn to display parts of text as bold or to put some links or icons into the listbox items. I tried to use a form with some success, but I stumbled across this issue: I want to close the popup as soon as the textbox loses focus to a control other than the popup. And I don´t now how to achieve this, because I can catch only the textbox.LostFocus event, but at that moment I need to know wether the focus went to the popup or somewhere else.
  3. Is there a way to extend the bounds of a control, so that it has some extra space between the physical boundary and the graphical edge? Look at the image in attachment that demonstrates what I want to achieve. In this case it is a datagridview with some extra space on the right. Sure, I could put it inside a usercontrol, but I want this control to Inherit directly from DataGridView.
  4. Hi, I am making a usercontrol containing a datagridview and some additional controls and I need to expose the Columns property of the datagridview in my usercontrol at design-time. I know that it isn´t as easy as "Public Property Grid as DataGridView ..." and I tried many of the workarounds that I found on the internet, but with no success. Obviously the best way is to write a custom ColumnCollectionEditor. Could someone please provide a complete solution for this problem in VB.Net? Thanks in advance.
  5. Hello, I wonder how do I make a usercontrol that pops up a listbox. Just like the search box in Google. The problem is, that when I put a listbox in my usercontrol, it displays within the control bounds. This list though needs to be displayed outside the control bounds. How do I do this?
  6. I figured it out my self. I put Dataset.AcceptChanges before Dataadapter.Fill and it worked :)
  7. A am trying to make a simple database application just to learn SQLCE. I can not get the simplest things to work: adding and deleting records. Here´s how it looks now: Conn = New SqlCeConnection(CS) 'set the connection Conn.Open() 'and open it 'the database has 1 table called Invoices and 2 columns. First column called ID (identity with auto increment set to true) is the primary key. Second is a string (nvarchar) column called InvoiceNo. TA = New SqlCeDataAdapter("SELECT * FROM Invoices", Conn) 'set the data adapter CB = New SqlCeCommandBuilder(TA) Dim DSF as New Dataset 'a blank dataset TA.Fill(DSF, "Invoices") 'filling the dataset DSF.Tables("Invoices").PrimaryKey = New DataColumn() {DSF.Tables("Invoices").Columns("ID")} 'I need a primary key to easily search for records in dataset by ID 'there is a DataGridView called DG on the form DG.DataSource = DSF DGFaktury.DataMember = "Invoices" Works nicely. Loads all data into the datagrid. Now I want to insert a record: Dim R As DataRow = DSF.Tables("Invoices").NewRow R.Item("InvoiceNo") = "027" DSF.Tables("Invoices").Rows.Add(R) TA.Update(DSF, "Invoices") 'so far so good I can get the new row into the database. But in my datagrid I see only the new InvoiceNo, but not the new ID. Of course the dataset doesn´t know what ID was assigned to the new row in the database, so I have to get it somehow. So here´s what I did. Dim cmd As New SqlCeCommand("SELECT ID FROM Invoices WHERE (ID = @@IDENTITY)", Conn) Dim id As Integer = CInt(cmd.ExecuteScalar()) R.Item("ID") = id 'now I see the ID of newly added record - wow Here comes the problem: there is a Delete button on my form. When I click it, and the newly added row in the datagrid is selected, it executes this: Dim ID As Integer = DG.SelectedRows(0).Cells("ID").Value 'retrieves the ID DSF.Tables("Invoices").Rows.Find(ID).Delete() 'finds a row in the dataset and deletes it TA.Update(DSF, "Invoices") I ended up with an exception: DBConcurrencyException, DeleteCommand affected 0 of 1 expected rows. After inserting the new row, the dataset changed when I changed the ID, so it thinks it has to update the record while deleting it at the same time and that´s what is causing the error. Is that right? There´s no problem while deleting older records. Am I going the right direction? Is there another way to get these simple operations (insert, delete, update) to work? I found tutorials dealing with wieving of data only, but not inserting, updating or deleting.
  8. Yes I need a scaled bitmap. Imagine this: 1- put a picturebox (width=200, height=100) onto a form in designer 2 - choose a background image (image width=50, image height=300) for the picturebox 3 - set the backgroundimagelayout property to "zoom" You´ll see that the background image zoomed nicely to fit in the picturebox by maintaining aspect ratio (ratio between width and height). My question is: how to get the image that I actually see in the picturebox? Sure, one way is to compare the aspect ratio of original image with the aspect ratio of the picturebox, calculate the actual size and then scale the original image to that. But is there some easier way?
  9. Hi there, I have a picturebox with BackgroundImageLayout set to Zoom. So when I resize the picturebox, the background resizes too maintaining its aspect ratio. How do I get the zoomed image instead of the original background image?
  10. okay, here it is. I´ve cut the code to the bone so that it still produces the error: Public Class Form1 Dim D3D As Direct3D.Device Dim PP As New PresentParameters() Dim vb As VertexBuffer = Nothing Dim Cam As New Vector3(0, 0, 10) Dim DeviceReady As Boolean = False Private Sub Form1_Shown(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Shown Dim dm As DisplayMode = Manager.Adapters.Default.CurrentDisplayMode With PP .Windowed = True .SwapEffect = SwapEffect.Discard .DeviceWindow = Panel1 .BackBufferFormat = Format.X8R8G8B8 .BackBufferWidth = Panel1.Width .BackBufferHeight = Panel1.Height .EnableAutoDepthStencil = True .AutoDepthStencilFormat = DepthFormat.D16 End With Try D3D = New Direct3D.Device(0, DeviceType.Hardware, Panel1, CreateFlags.HardwareVertexProcessing, PP) AddHandler D3D.DeviceLost, AddressOf Me.OnDeviceLost AddHandler D3D.DeviceReset, AddressOf Me.OnResetDevice AddHandler D3D.DeviceResizing, AddressOf Me.OnDeviceResizing Catch ex As Exception MsgBox("Error in creating device! " & ex.Message, MsgBoxStyle.Exclamation, "Some error!") Exit Sub End Try vb = New VertexBuffer(GetType(CustomVertex.PositionNormalColored), 36, D3D, Usage.Dynamic And Usage.WriteOnly, CustomVertex.PositionColored.Format, Pool.Managed) vb.SetData(New Cube(2, 1, 0.5, Color.SkyBlue).GetVerts, 0, LockFlags.None) SetupLights() DeviceReady = True Panel1.Invalidate() End Sub Private Sub SetupLights() With D3D .Lights(0).Type = LightType.Point .Lights(0).Position = New Vector3(-2, 7, 3) .Lights(0).Ambient = System.Drawing.Color.White .Lights(0).Attenuation0 = 0.8F .Lights(0).Attenuation1 = 0.02F .Lights(0).Range = 10000.0F .Lights(0).Enabled = True With .PresentationParameters .BackBufferWidth = Panel1.Width .BackBufferHeight = Panel1.Height End With End With End Sub Private Sub OnDeviceLost() End Sub Private Sub OnResetDevice() End Sub Private Sub OnDeviceResizing() My.Application.DoEvents() SetupLights() Panel1.Invalidate() End Sub Private Sub Render() With D3D .Clear(ClearFlags.Target Or ClearFlags.ZBuffer, Color.Black, 1, 0) .BeginScene() .Transform.View = Matrix.LookAtLH(cam, New Vector3(0, 0, 0), New Vector3(0, 1, 0)) .Transform.Projection = Matrix.PerspectiveFovLH(0.8, Panel1.Width / Panel1.Height, 1, 1000) 'drawing cube .SetStreamSource(0, vb, 0) .VertexFormat = CustomVertex.PositionNormalColored.Format .Transform.World = Matrix.Translation(New Vector3(0, 0, 0)) .RenderState.Lighting = True .DrawPrimitives(PrimitiveType.TriangleList, 0, 12) .EndScene() My.Application.DoEvents() .Present() End With End Sub Private Sub Panel1_Paint(ByVal sender As Object, ByVal e As System.Windows.Forms.PaintEventArgs) Handles Panel1.Paint Render() End Sub End Class Public Class Cube Public X As Single Public Y As Single Public Z As Single Public [Color] As Color Public Sub New(ByVal Length As Single, ByVal Width As Single, ByVal Height As Single, ByVal CubeColor As Color) X = Length Y = Width Z = Height [Color] = CubeColor End Sub Public Function GetVerts() As CustomVertex.PositionNormalColored() 'This gets the vertexes of the cube. Each face is composed of 2 triangles. 'Each triangle has 3 vertexes, so each face needs 6 vertexes; i.e. some vertexes 'are written twice. The order in which you build the vertexes determine which 'side gets filled. You plot vertexes counter-clockwise for sides facing the camera 'and clockwise for ones facing "away". 'Also, in order for each side to be lit, you need to specify the 'normal for each vertex. This is the same number for all vertexes on each side. 'Setting the normal improperly can give some interesting effects in lighting. Dim X2 As Single = X / 2 Dim Y2 As Single = Y / 2 Dim Z2 As Single = Z / 2 Dim verts(35) As CustomVertex.PositionNormalColored 'Front face. verts(0) = New CustomVertex.PositionNormalColored(New Vector3(-X2, Y2, Z2), New Vector3(0, 0, 1), [Color].ToArgb()) verts(1) = New CustomVertex.PositionNormalColored(New Vector3(-X2, -Y2, Z2), New Vector3(0, 0, 1), [Color].ToArgb()) verts(2) = New CustomVertex.PositionNormalColored(New Vector3(X2, Y2, Z2), New Vector3(0, 0, 1), [Color].ToArgb()) verts(3) = New CustomVertex.PositionNormalColored(New Vector3(-X2, -Y2, Z2), New Vector3(0, 0, 1), [Color].ToArgb()) verts(4) = New CustomVertex.PositionNormalColored(New Vector3(X2, -Y2, Z2), New Vector3(0, 0, 1), [Color].ToArgb()) verts(5) = New CustomVertex.PositionNormalColored(New Vector3(X2, Y2, Z2), New Vector3(0, 0, 1), [Color].ToArgb()) 'Back face. This is facing away from the camera, so vertices should be clockwise order. verts(6) = New CustomVertex.PositionNormalColored(New Vector3(-X2, Y2, -Z2), New Vector3(0, 0, -1), [Color].ToArgb()) verts(7) = New CustomVertex.PositionNormalColored(New Vector3(X2, Y2, -Z2), New Vector3(0, 0, -1), [Color].ToArgb()) verts(8) = New CustomVertex.PositionNormalColored(New Vector3(-X2, -Y2, -Z2), New Vector3(0, 0, -1), [Color].ToArgb()) verts(9) = New CustomVertex.PositionNormalColored(New Vector3(-X2, -Y2, -Z2), New Vector3(0, 0, -1), [Color].ToArgb()) verts(10) = New CustomVertex.PositionNormalColored(New Vector3(X2, Y2, -Z2), New Vector3(0, 0, -1), [Color].ToArgb()) verts(11) = New CustomVertex.PositionNormalColored(New Vector3(X2, -Y2, -Z2), New Vector3(0, 0, -1), [Color].ToArgb()) 'Top face. verts(12) = New CustomVertex.PositionNormalColored(New Vector3(-X2, Y2, Z2), New Vector3(0, 1, 0), [Color].ToArgb()) verts(13) = New CustomVertex.PositionNormalColored(New Vector3(X2, Y2, -Z2), New Vector3(0, 1, 0), [Color].ToArgb()) verts(14) = New CustomVertex.PositionNormalColored(New Vector3(-X2, Y2, -Z2), New Vector3(0, 1, 0), [Color].ToArgb()) verts(15) = New CustomVertex.PositionNormalColored(New Vector3(-X2, Y2, Z2), New Vector3(0, 1, 0), [Color].ToArgb()) verts(16) = New CustomVertex.PositionNormalColored(New Vector3(X2, Y2, Z2), New Vector3(0, 1, 0), [Color].ToArgb()) verts(17) = New CustomVertex.PositionNormalColored(New Vector3(X2, Y2, -Z2), New Vector3(0, 1, 0), [Color].ToArgb()) 'Bottom face. This is facing away from the camera, so vertices should be clockwise order. verts(18) = New CustomVertex.PositionNormalColored(New Vector3(-X2, -Y2, Z2), New Vector3(0, -1, 0), [Color].ToArgb()) verts(19) = New CustomVertex.PositionNormalColored(New Vector3(-X2, -Y2, -Z2), New Vector3(0, -1, 0), [Color].ToArgb()) verts(20) = New CustomVertex.PositionNormalColored(New Vector3(X2, -Y2, -Z2), New Vector3(0, -1, 0), [Color].ToArgb()) verts(21) = New CustomVertex.PositionNormalColored(New Vector3(-X2, -Y2, Z2), New Vector3(0, -1, 0), [Color].ToArgb()) verts(22) = New CustomVertex.PositionNormalColored(New Vector3(X2, -Y2, -Z2), New Vector3(0, -1, 0), [Color].ToArgb()) verts(23) = New CustomVertex.PositionNormalColored(New Vector3(X2, -Y2, Z2), New Vector3(0, -1, 0), [Color].ToArgb()) 'Left face. verts(24) = New CustomVertex.PositionNormalColored(New Vector3(-X2, Y2, Z2), New Vector3(-1, 0, 0), [Color].ToArgb()) verts(25) = New CustomVertex.PositionNormalColored(New Vector3(-X2, -Y2, -Z2), New Vector3(-1, 0, 0), [Color].ToArgb()) verts(26) = New CustomVertex.PositionNormalColored(New Vector3(-X2, -Y2, Z2), New Vector3(-1, 0, 0), [Color].ToArgb()) verts(27) = New CustomVertex.PositionNormalColored(New Vector3(-X2, Y2, -Z2), New Vector3(-1, 0, 0), [Color].ToArgb()) verts(28) = New CustomVertex.PositionNormalColored(New Vector3(-X2, -Y2, -Z2), New Vector3(-1, 0, 0), [Color].ToArgb()) verts(29) = New CustomVertex.PositionNormalColored(New Vector3(-X2, Y2, Z2), New Vector3(-1, 0, 0), [Color].ToArgb()) 'Right face. This is facing away from the camera, so vertices should be clockwise order. verts(30) = New CustomVertex.PositionNormalColored(New Vector3(X2, Y2, Z2), New Vector3(1, 0, 0), [Color].ToArgb()) verts(31) = New CustomVertex.PositionNormalColored(New Vector3(X2, -Y2, Z2), New Vector3(1, 0, 0), [Color].ToArgb()) verts(32) = New CustomVertex.PositionNormalColored(New Vector3(X2, -Y2, -Z2), New Vector3(1, 0, 0), [Color].ToArgb()) verts(33) = New CustomVertex.PositionNormalColored(New Vector3(X2, Y2, -Z2), New Vector3(1, 0, 0), [Color].ToArgb()) verts(34) = New CustomVertex.PositionNormalColored(New Vector3(X2, Y2, Z2), New Vector3(1, 0, 0), [Color].ToArgb()) verts(35) = New CustomVertex.PositionNormalColored(New Vector3(X2, -Y2, -Z2), New Vector3(1, 0, 0), [Color].ToArgb()) Return verts End Function End Class
  11. Hi, I am wondering how do I minimize a windowed DirectX application without getting an application error. Like in various tutorials, I captured the OnDeviceLost event, but what do I have to put inside it? The application displays a simple cube without textures and it uses 1 light. There is no rendering loop running. The rendering block is called only if needed (i.e. setting viewer position, setting light color etc.).
  12. I finally solved it. It was just a matter of setting the proper BackBufferFormat. I chose 'Format.X8R8G8B8' instead of 'Manager.Adapters.Default.CurrentDisplayMode.Format'. Using the previous format didn´t allow the use of a DepthStencil.
  13. Im am trying to solve a simple problem: in my DirectX9 application (VB.Net) I draw a simple lit cube using trianglestrip and a grid (just like every 3D editing software) using linelist. But when move the camera in the opposite position to look at the cube from behind, the grid is drawn in front of the cube, even it should be behind it. In code, the grid is drawn first and the cube is drawn afterwards. When i change the order, it doesn´t help, except that the grid visibility is inverted against the first case. Seems like lines are not depth-tested. How do I properly combine solid geometry with lines?
  14. Hi, I need a lot of help with this issue: I am developing a simple custom control. The control has a custom property. This custom property contains another custom property. I am not sure what is the right way to achieve it. The attached image says what I need to do. When I change the width or color property at design or runtime, I can´t capture the change - it simply doesn´t update. The code I am using looks like this: Public Class MyUC Private _Circle as MyCircle Public Property Circle() as MyCircle Get Circle = _Circle End Get Set(ByVal value As MyCircle) _Circle = value mylabel.Text = __Circle.Border.Width 'this doesn´t execute at all. WHY? End Set End Property End Class <TypeConverter(GetType(ExpandableObjectConverter))> _ Public Class MyCircle Private _Border As New MyBorder() <NotifyParentProperty(True), _ RefreshProperties(RefreshProperties.All)> _ Public Property Border() As MyBorder Get Border = _Border End Get Set(ByVal value As MyBorder) _Border = value 'this line also doesn´t execute End Set End Property End Class <TypeConverter(GetType(ExpandableObjectConverter))> _ Public Class MyBorder Private _Width As Integer = 1 Private _Color As Color = Color.Black <NotifyParentProperty(True), _ RefreshProperties(RefreshProperties.All)> _ Public Property Width() As Integer Get Return _Width End Get Set(ByVal value As Integer) _Width = value End Set End Property <NotifyParentProperty(True), _ RefreshProperties(RefreshProperties.All)> _ Public Property Color() as Color Get Return _Color End Get Set(ByVal value As Integer) _Color = value End Set End Class I want the control´s expandable properties to work properly - just like those in DevExpress Controls
×
×
  • Create New...